[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 20011231: netCDF C++ interface



>To: address@hidden
>From: Michael Dixon <address@hidden>
>Subject: netCDF C++ interface
>Organization: NCAR/RAP
>Keywords: 200112312242.fBVMg3N20826 netCDF C++

Mike,

In my previous reply, I forgot to answer your last question:

> Perhaps it would be worth adding a strerror() type function to
> the error class? Or do you have suggestions on how best to use
> the NcError class?

The default behavior of the error class is NcError::verbose_fatal,
which means if you don't even bother with checking error returns, any
error detected will result in an error message being written to stderr
and termination.  Sort of like the behavior when you don't catch an
exception.

The intention was to modify this behavior when you want to handle
errors yourself by declaring an NcError object with a different
behavior.  For example, if there is a section of your program where
you are checking netCDF attributes and expect an attribute might not
exist, you could wrap it in something like:

 {
   NcError* xerror = new NcError(NcError::silent_nonfatal);
      ...
   NcAtt* testatt = P->get_att("some_attribute");
   if (testatt == 0) {
      // handle nonexistence of attribute
   }
   ...
 }

--Russ