Skip to content
Permalink
Browse files

NetCDF_Utils: two variants of ncCheck

(cherry picked from commit 40ede8c)
  • Loading branch information...
alexander-buerger-met-no committed Aug 9, 2016
1 parent 56d848e commit 9b68de122985b67dc92b4ac6df0298380cab7a4a
Showing with 22 additions and 6 deletions.
  1. +20 −5 src/NetCDF_Utils.cc
  2. +2 −1 src/NetCDF_Utils.h
@@ -44,11 +44,26 @@ static LoggerPtr logger = getLogger("fimex.NetCDF_Utils");
// hdf5 lib is usually not thread-safe, so reading from one file and writing to another fails
static MutexType ncMutex;

void ncCheck(int status, std::string msg) {
std::string outMsg("");
if (msg != "") outMsg = " : "+msg;
if (status != NC_NOERR)
throw CDMException(nc_strerror(status) + outMsg);
void ncCheck(int status)
{
if (status != NC_NOERR) {
throw CDMException(nc_strerror(status));
}
}

void ncCheck(int status, const std::string& msg)
{
if (status != NC_NOERR) {
if (msg.empty()) {
throw CDMException(nc_strerror(status));
} else {
std::ostringstream out;
out << nc_strerror(status);
out << " : " << msg;
throw CDMException(out.str());
}
}
}

Nc::Nc()
: isOpen(false)
@@ -71,7 +71,8 @@ CDMDataType ncType2cdmDataType(nc_type nctype);
/**
* read a nc-status and throw an error if status != NC_NOERR
*/
void ncCheck(int status, std::string msg="");
void ncCheck(int status);
void ncCheck(int status, const std::string& msg);

/**
* read values from an attribute to a data

0 comments on commit 9b68de1

Please sign in to comment.
You can’t perform that action at this time.