1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308
|
#include <ncException.h>
#include <sstream>
#include <netcdf.h>
using namespace std;
using namespace netCDF;
using namespace netCDF::exceptions;
// Default object thrown if a netCDF exception is encountered.
/*NcException::NcException(const string& complaint,const char* fileName,int lineNumber)
: what_msg(NULL)
, ec(0)
{
try{
std::ostringstream oss;
oss << lineNumber;
what_msg = new std::string(complaint+"\nfile: "+fileName+" line:"+oss.str());
}catch(...){
what_msg = NULL;
}
}*/
NcException::NcException(const char* complaint,const char* fileName,int lineNumber)
: what_msg(NULL)
, ec(0)
{
try{
std::ostringstream oss;
oss << lineNumber;
what_msg = new std::string(complaint?complaint:"");
what_msg->append("\nfile: ");
what_msg->append(fileName);
what_msg->append(" line:");
what_msg->append(oss.str());
}catch(...){
what_msg = NULL;
}
}
NcException::NcException(int errorCode, const char* complaint,const char* fileName,int lineNumber)
: what_msg(NULL)
, ec(errorCode)
{
try{
std::ostringstream oss;
oss << lineNumber;
what_msg = new std::string(complaint?complaint:"");
what_msg->append("\nfile: ");
what_msg->append(fileName);
what_msg->append(" line:");
what_msg->append(oss.str());
}catch(...){
what_msg = NULL;
}
}
NcException::NcException(const NcException& e) throw()
: what_msg(NULL)
, ec(e.ec)
{
try{
what_msg = new std::string(*(e.what_msg));
}catch(...){
what_msg = NULL;
}
}
NcException& NcException::operator=(const NcException& e) throw(){
if (this != &e){
ec = e.ec;
delete what_msg;
try{
what_msg = new std::string(*(e.what_msg));
}catch(...){
what_msg = NULL;
}
}
return *this;
}
NcException::~NcException()throw() {
delete what_msg;
}
const char* NcException::what() const throw()
{
return what_msg==NULL ? "" : what_msg->c_str();
}
int NcException::errorCode() const throw() {
return ec;
}
// Thrown if the specified netCDF ID does not refer to an open netCDF dataset.
NcBadId::NcBadId(const char* complaint,const char* file,int line) :
NcException(NC_EBADID,complaint,file,line) { }
// Thrown if too many netcdf files are open.
NcNFile::NcNFile(const char* complaint,const char* file,int line) :
NcException(NC_ENFILE,complaint,file,line) { }
// Thrown if, having set NC_NOCLOBBER, the specified dataset already exists.
NcExist::NcExist(const char* complaint,const char* file,int line) :
NcException(NC_EEXIST,complaint,file,line) { }
// Thrown if not a netCDF id.
NcInvalidArg::NcInvalidArg(const char* complaint,const char* file,int line) :
NcException(NC_EINVAL,complaint,file,line) { }
// Thrown if invalid argument.
NcInvalidWrite::NcInvalidWrite(const char* complaint,const char* file,int line) :
NcException(NC_EPERM,complaint,file,line) { }
// Thrown if operation not allowed in data mode.
NcNotInDefineMode::NcNotInDefineMode(const char* complaint,const char* file,int line) :
NcException(NC_ENOTINDEFINE,complaint,file,line) { }
// Thrown if operation not allowed in defined mode.
NcInDefineMode::NcInDefineMode(const char* complaint,const char* file,int line) :
NcException(NC_EINDEFINE,complaint,file,line) { }
// Index exceeds dimension bound
NcInvalidCoords::NcInvalidCoords(const char* complaint,const char* file,int line) :
NcException(NC_EINVALCOORDS,complaint,file,line) { }
// Thrown if NC_MAX_DIMS is exceeded.
NcMaxDims::NcMaxDims(const char* complaint,const char* file,int line) :
NcException(NC_EMAXDIMS,complaint,file,line) { }
// Thrown if string match to name is in use.
NcNameInUse::NcNameInUse(const char* complaint,const char* file,int line) :
NcException(NC_ENAMEINUSE,complaint,file,line) { }
// Thrown if attribute is not found.
NcNotAtt::NcNotAtt(const char* complaint,const char* file,int line) :
NcException(NC_ENOTATT,complaint,file,line) { }
// Thrown if Nc_MAX_ATTRS is exceeded.
NcMaxAtts::NcMaxAtts(const char* complaint,const char* file,int line) :
NcException(NC_EMAXATTS,complaint,file,line) { }
// Thrown if not a valid netCDF data type.
NcBadType::NcBadType(const char* complaint,const char* file,int line) :
NcException(NC_EBADTYPE,complaint,file,line) { }
// Thrown if an invalid dimension id or name.
NcBadDim::NcBadDim(const char* complaint,const char* file,int line) :
NcException(NC_EBADDIM,complaint,file,line) { }
// Thrown if Nc_UNLIMITED is in the wrong index.
NcUnlimPos::NcUnlimPos(const char* complaint,const char* file,int line) :
NcException(NC_EUNLIMPOS,complaint,file,line) { }
// Thrown if NC_MAX_VARS is exceeded.
NcMaxVars::NcMaxVars(const char* complaint,const char* file,int line) :
NcException(NC_EMAXVARS,complaint,file,line) { }
// Thrown if variable is not found.
NcNotVar::NcNotVar(const char* complaint,const char* file,int line) :
NcException(NC_ENOTVAR,complaint,file,line) { }
// Thrown if the action is prohibited on the NC_GLOBAL varid.
NcGlobal::NcGlobal(const char* complaint,const char* file,int line) :
NcException(NC_EGLOBAL,complaint,file,line) { }
// Thrown if not a netCDF file.
NcNotNCF::NcNotNCF(const char* complaint,const char* file,int line) :
NcException(NC_ENOTNC,complaint,file,line) { }
// Thrown if in FORTRAN, string is too short.
NcSts::NcSts(const char* complaint,const char* file,int line) :
NcException(NC_ESTS,complaint,file,line) { }
// Thrown if NC_MAX_NAME is exceeded.
NcMaxName::NcMaxName(const char* complaint,const char* file,int line) :
NcException(NC_EMAXNAME,complaint,file,line) { }
// Thrown if NC_UNLIMITED size is already in use.
NcUnlimit::NcUnlimit(const char* complaint,const char* file,int line) :
NcException(NC_EUNLIMIT,complaint,file,line) { }
// Thrown if nc_rec op when there are no record vars.
NcNoRecVars::NcNoRecVars(const char* complaint,const char* file,int line) :
NcException(NC_ENORECVARS,complaint,file,line) { }
// Thrown if attempt to convert between text and numbers.
NcChar::NcChar(const char* complaint,const char* file,int line) :
NcException(NC_ECHAR,complaint,file,line) { }
// Thrown if edge+start exceeds dimension bound.
NcEdge::NcEdge(const char* complaint,const char* file,int line) :
NcException(NC_EEDGE,complaint,file,line) { }
// Thrown if illegal stride.
NcStride::NcStride(const char* complaint,const char* file,int line) :
NcException(NC_ESTRIDE,complaint,file,line) { }
// Thrown if attribute or variable name contains illegal characters.
NcBadName::NcBadName(const char* complaint,const char* file,int line) :
NcException(NC_EBADNAME,complaint,file,line) { }
// Thrown if math result not representable.
NcRange::NcRange(const char* complaint,const char* file,int line) :
NcException(NC_ERANGE,complaint,file,line) { }
// Thrown if memory allocation (malloc) failure.
NcNoMem::NcNoMem(const char* complaint,const char* file,int line) :
NcException(NC_ENOMEM,complaint,file,line) { }
// Thrown if one or more variable sizes violate format constraints
NcVarSize::NcVarSize(const char* complaint,const char* file,int line) :
NcException(NC_EVARSIZE,complaint,file,line) { }
// Thrown if invalid dimension size.
NcDimSize::NcDimSize(const char* complaint,const char* file,int line) :
NcException(NC_EDIMSIZE,complaint,file,line) { }
// Thrown if file likely truncated or possibly corrupted.
NcTrunc::NcTrunc(const char* complaint,const char* file,int line) :
NcException(NC_ETRUNC,complaint,file,line) { }
// Thrown if an error was reported by the HDF5 layer.
NcHdfErr::NcHdfErr(const char* complaint,const char* file,int line) :
NcException(NC_EHDFERR,complaint,file,line) { }
// Thrown if cannot read.
NcCantRead::NcCantRead(const char* complaint,const char* file,int line) :
NcException(NC_ECANTREAD,complaint,file,line) { }
// Thrown if cannot write.
NcCantWrite::NcCantWrite(const char* complaint,const char* file,int line) :
NcException(NC_ECANTWRITE,complaint,file,line) { }
// Thrown if cannot create.
NcCantCreate::NcCantCreate(const char* complaint,const char* file,int line) :
NcException(NC_ECANTCREATE,complaint,file,line) { }
// Thrown if file meta.
NcFileMeta::NcFileMeta(const char* complaint,const char* file,int line) :
NcException(NC_EFILEMETA,complaint,file,line) { }
// Thrown if dim meta.
NcDimMeta::NcDimMeta(const char* complaint,const char* file,int line) :
NcException(NC_EDIMMETA,complaint,file,line) { }
// Thrown if attribute meta.
NcAttMeta::NcAttMeta(const char* complaint,const char* file,int line) :
NcException(NC_EATTMETA,complaint,file,line) { }
// Thrown if variable meta.
NcVarMeta::NcVarMeta(const char* complaint,const char* file,int line) :
NcException(NC_EVARMETA,complaint,file,line) { }
// Thrown if no compound.
NcNoCompound::NcNoCompound(const char* complaint,const char* file,int line) :
NcException(NC_ENOCOMPOUND,complaint,file,line) { }
// Thrown if attribute exists.
NcAttExists::NcAttExists(const char* complaint,const char* file,int line) :
NcException(NC_EATTEXISTS,complaint,file,line) { }
// Thrown if attempting netcdf-4 operation on netcdf-3 file.
NcNotNc4::NcNotNc4(const char* complaint,const char* file,int line) :
NcException(NC_ENOTNC4,complaint,file,line) { }
// Thrown if attempting netcdf-4 operation on strict nc3 netcdf-4 file.
NcStrictNc3::NcStrictNc3(const char* complaint,const char* file,int line) :
NcException(NC_ESTRICTNC3,complaint,file,line) { }
// Thrown if bad group id.
NcBadGroupId::NcBadGroupId(const char* complaint,const char* file,int line) :
NcException(NC_EBADGRPID,complaint,file,line) { }
// Thrown if bad type id.
NcBadTypeId::NcBadTypeId(const char* complaint,const char* file,int line) :
NcException(NC_EBADTYPID,complaint,file,line) { }
// Thrown if bad field id.
NcBadFieldId::NcBadFieldId(const char* complaint,const char* file,int line) :
NcException(NC_EBADFIELD,complaint,file,line) { }
// Thrown if cannot find the field id.
NcUnknownName::NcUnknownName(const char* complaint,const char* file,int line) :
NcException(complaint,file,line) { }
// Thrown if cannot find the field id.
NcEnoGrp::NcEnoGrp(const char* complaint,const char* file,int line) :
NcException(NC_ENOGRP,complaint,file,line) { }
// Thrown if cannot find the field id.
NcNullGrp::NcNullGrp(const char* complaint,const char* file,int line) :
NcException(complaint,file,line) { }
// Thrown if cannot find the field id.
NcNullDim::NcNullDim(const char* complaint,const char* file,int line) :
NcException(complaint,file,line) { }
// Thrown if cannot find the field id.
NcNullType::NcNullType(const char* complaint,const char* file,int line) :
NcException(complaint,file,line) { }
// Thrown if an operation to set the deflation, chunking, endianness, fill, compression, or checksum of a NcVar object is issued after a call to NcVar::getVar or NcVar::putVar.
NcElateDef::NcElateDef(const char* complaint,const char* file,int line) :
NcException(NC_ELATEDEF,complaint,file,line) { }
|