icedb  version 0.5.1
Snow particle scattering database API
Classes | Typedefs | Enumerations | Functions
icedb::error Namespace Reference

Classes

class  error_options_inner
 
class  xError
 

Typedefs

typedef std::shared_ptr< xErrorxError_ptr
 
typedef ICEDB_error_code error_code_t
 
typedef std::shared_ptr< ICEDB_error_contexterror_context_pt
 
typedef ICEDB_ERRORCODES error_codes
 

Enumerations

enum  error_types {
  error_types::xDivByZero, error_types::xInvalidRange, error_types::xAssert, error_types::xBadInput,
  error_types::xNullPointer, error_types::xModelOutOfRange, error_types::xMissingFrequency, error_types::xEmptyInputFile,
  error_types::xMissingFolder, error_types::xMissingFile, error_types::xMissingVariable, error_types::xMissingConfigurationFile,
  error_types::xFileExists, error_types::xPathExistsWrongType, error_types::xTypeMismatch, error_types::xUnknownFileFormat,
  error_types::xMissingKey, error_types::xMissingHash, error_types::xKeyExists, error_types::xUnimplementedFunction,
  error_types::xFallbackTemplate, error_types::xArrayOutOfBounds, error_types::xDimensionMismatch, error_types::xSingular,
  error_types::xDLLversionMismatch, error_types::xDuplicateHook, error_types::xHandleInUse, error_types::xHandleNotOpen,
  error_types::xSymbolNotFound, error_types::xBadFunctionMap, error_types::xBadFunctionReturn, error_types::xBlockedHookLoad,
  error_types::xBlockedHookUnload, error_types::xDLLerror, error_types::xUpcast, error_types::xCannotFindReference,
  error_types::xOtherError, error_types::xUnsupportedIOaction
}
 

Functions

 DOTYPES (IMPL_xError_ADD)
 
template<>
DL_ICEDB std::string stringify< std::string > (error_code_t err)
 
template<>
DL_ICEDB const char * stringify< const char * > (error_code_t err)
 
DL_ICEDB error_context_pt get_error_context_thread_local ()
 
DL_ICEDB void stringify (error_code_t err, std::string &res)
 
DL_ICEDB void stringify (error_code_t err, const char **res)
 
DL_ICEDB void stringify (const error_context_pt &err, std::string &res)
 
DL_ICEDB std::string stringify (const error_context_pt &err)
 
DL_ICEDB error_code_t error_context_to_code (const error_context_pt &err)
 
const char * stringify (error_types et)
 
template<class StringType >
StringType stringify (error_code_t err)
 
template<>
DL_ICEDB std::string stringify (error_code_t err)
 
template<>
DL_ICEDB const char * stringify (error_code_t err)
 

Typedef Documentation

◆ error_code_t

Defines an error condition. This is an integer. Zero (0) indicates that there is no error.

Definition at line 42 of file error.hpp.

◆ error_codes

Definition at line 12 of file errorCodes.hpp.

◆ error_context_pt

Defines an error context. This structure contains both an error code (for fast lookups) and any ancillary information to determine why / how the error occurred. The library keeps an internal buffer of these objects, and copies them when the program requests them. It is then the programmer's job to free all instances that are thus marshalled.

Definition at line 56 of file error.hpp.

◆ xError_ptr

typedef std::shared_ptr<xError> icedb::error::xError_ptr

Definition at line 13 of file error.hpp.

Enumeration Type Documentation

◆ error_types

Enumerator
xDivByZero 
xInvalidRange 
xAssert 
xBadInput 
xNullPointer 
xModelOutOfRange 
xMissingFrequency 
xEmptyInputFile 
xMissingFolder 
xMissingFile 
xMissingVariable 
xMissingConfigurationFile 
xFileExists 
xPathExistsWrongType 
xTypeMismatch 
xUnknownFileFormat 
xMissingKey 
xMissingHash 
xKeyExists 
xUnimplementedFunction 
xFallbackTemplate 
xArrayOutOfBounds 
xDimensionMismatch 
xSingular 
xDLLversionMismatch 
xDuplicateHook 
xHandleInUse 
xHandleNotOpen 
xSymbolNotFound 
xBadFunctionMap 
xBadFunctionReturn 
xBlockedHookLoad 
xBlockedHookUnload 
xDLLerror 
xUpcast 
xCannotFindReference 
xOtherError 
xUnsupportedIOaction 

Definition at line 5 of file errorTypes.hpp.

5  {
8  xAssert,
9  xBadInput,
24  xKeyExists,
29  xSingular,
39  xDLLerror,
40  xUpcast,
44  };

Function Documentation

◆ DOTYPES()

icedb::error::DOTYPES ( IMPL_xError_ADD  )

◆ error_context_to_code()

DL_ICEDB error_code_t icedb::error::error_context_to_code ( const error_context_pt )

Get the error code from the context. Shouldn't be necessary.

Definition at line 327 of file error.cpp.

References ICEDB_error_context_to_code.

327 { return ICEDB_error_context_to_code(err.get()); }
DL_ICEDB ICEDB_error_context_to_code_f ICEDB_error_context_to_code
Definition: error.cpp:21

◆ get_error_context_thread_local()

DL_ICEDB error_context_pt icedb::error::get_error_context_thread_local ( )

Copy the last error context raised within the active thread. The resulting object should be freed once no longer needed. Returns NULL if no context exists.

Definition at line 303 of file error.cpp.

References error_context_deallocate(), and get_error_context_thread_local_c().

303  {
305  }
std::shared_ptr< ICEDB_error_context > error_context_pt
Definition: error.hpp:56
void error_context_deallocate(struct ICEDB_error_context *c)
Definition: error.cpp:170
struct ICEDB_error_context * get_error_context_thread_local_c()
Definition: error.cpp:164
Here is the call graph for this function:

◆ stringify() [1/8]

const char * icedb::error::stringify ( error_types  et)

Definition at line 4 of file errorTypes.cpp.

References xArrayOutOfBounds, xAssert, xBadFunctionMap, xBadFunctionReturn, xBadInput, xBlockedHookLoad, xBlockedHookUnload, xCannotFindReference, xDimensionMismatch, xDivByZero, xDLLerror, xDLLversionMismatch, xDuplicateHook, xEmptyInputFile, xFallbackTemplate, xFileExists, xHandleInUse, xHandleNotOpen, xInvalidRange, xKeyExists, xMissingConfigurationFile, xMissingFile, xMissingFolder, xMissingFrequency, xMissingHash, xMissingKey, xMissingVariable, xModelOutOfRange, xNullPointer, xOtherError, xPathExistsWrongType, xSingular, xSymbolNotFound, xTypeMismatch, xUnimplementedFunction, xUnknownFileFormat, xUnsupportedIOaction, and xUpcast.

4  {
5  if (et == error_types::xDivByZero) return "Division by zero.";
6  else if (et == error_types::xInvalidRange) return "Invalid range.";
7  else if (et == error_types::xAssert) return "Assertion failed.";
8  else if (et == error_types::xBadInput) return "Bad or nonsensical input.";
9  else if (et == error_types::xNullPointer) return "An unexpected null pointer was encountered.";
10  else if (et == error_types::xModelOutOfRange) return "Model out of range.";
11  else if (et == error_types::xMissingFrequency) return "Missing data for this frequency.";
12  else if (et == error_types::xEmptyInputFile) return "Input file is empty.";
13  else if (et == error_types::xMissingFolder) return "Missing folder in path.";
14  else if (et == error_types::xMissingFile) return "Missing file.";
15  else if (et == error_types::xMissingVariable) return "Missing variable in a saved structure.";
16  else if (et == error_types::xMissingConfigurationFile) return "Cannot find an appropriate configuration file.";
17  else if (et == error_types::xFileExists) return "File to be opened for writing already exists.";
18  else if (et == error_types::xPathExistsWrongType) return "Path exists, but wrong type (i.e. file vs. directory).";
19  else if (et == error_types::xTypeMismatch) return "Variable does not have the correct type.";
20  else if (et == error_types::xUnknownFileFormat) return "Unknown file format.";
21  else if (et == error_types::xMissingKey) return "Key not found in map.";
22  else if (et == error_types::xMissingHash) return "Cannot find hash to load.";
23  else if (et == error_types::xKeyExists) return "Key already exists in map.";
24  else if (et == error_types::xUnimplementedFunction) return "Unimplemented function.";
25  else if (et == error_types::xFallbackTemplate) return "Reached point in code that is the fallback template. Missing the appropriate template specialization.";
26  else if (et == error_types::xArrayOutOfBounds) return "An array went out of bounds.";
27  else if (et == error_types::xDimensionMismatch) return "An array went out of bounds.";
28  else if (et == error_types::xSingular) return "Singular matrix detected.";
29  else if (et == error_types::xDLLversionMismatch) return "Attempting to load a DLL that is compiled against an incompatible library version.";
30  else if (et == error_types::xDuplicateHook) return "Attempting to load same DLL twice.";
31  else if (et == error_types::xHandleInUse) return "DLL handle is currently in use, but the code wants to overwrite it.";
32  else if (et == error_types::xHandleNotOpen) return "Attempting to access unopened DLL handle.";
33  else if (et == error_types::xSymbolNotFound) return "Cannot find symbol in DLL.";
34  else if (et == error_types::xBadFunctionMap) return "DLL symbol function map table is invalid.";
35  else if (et == error_types::xBadFunctionReturn) return "DLL symbol map table is invalid.";
36  else if (et == error_types::xBlockedHookLoad) return "Another hook blocked the load operation (for DLLs).";
37  else if (et == error_types::xBlockedHookUnload) return "Another DLL depends on the one that you are unloading.";
38  else if (et == error_types::xDLLerror) return "Unspecified DLL ICEDB_LOG_ERROR.";
39  else if (et == error_types::xUpcast) return "Plugin failure: cannot cast base upwards to a derived class provided by a plugin. Usually means that no matching plugin can be found.";
40  else if (et == error_types::xCannotFindReference) return "Cannot find reference in file.";
41  else if (et == error_types::xOtherError) return "Nonspecific ICEDB_LOG_ERROR.";
42  else if (et == error_types::xUnsupportedIOaction) return "Unsupported IO action.";
43  else return "INVALID - stringify does not have the appropriate ICEDB_LOG_ERROR type!";
44  }

◆ stringify() [2/8]

template<class StringType >
StringType icedb::error::stringify ( error_code_t  err)

Definition at line 46 of file error.hpp.

References DL_ICEDB, and stringify().

46 { return StringType(); }
Here is the call graph for this function:

◆ stringify() [3/8]

template<>
DL_ICEDB std::string icedb::error::stringify ( error_code_t  err)

Definition at line 46 of file error.hpp.

46 { return StringType(); }

◆ stringify() [4/8]

template<>
DL_ICEDB const char* icedb::error::stringify ( error_code_t  err)

Definition at line 46 of file error.hpp.

References DL_ICEDB, and stringify().

46 { return StringType(); }
Here is the call graph for this function:

◆ stringify() [5/8]

DL_ICEDB void icedb::error::stringify ( error_code_t  err,
std::string &  res 
)

Definition at line 307 of file error.cpp.

References ICEDB_ERRORCODES_MAP.

Referenced by stringify(), stringify< std::string >(), and icedb::error::xError::what().

307  {
308  res = std::string(ICEDB_ERRORCODES_MAP[err]);
309  }
ICEDB_SYMBOL_PRIVATE const char * ICEDB_ERRORCODES_MAP[ICEDB_ERRORCODES_TOTAL]
Definition: errorCodes.cpp:3
Here is the caller graph for this function:

◆ stringify() [6/8]

DL_ICEDB void icedb::error::stringify ( error_code_t  err,
const char **  res 
)

Definition at line 310 of file error.cpp.

References ICEDB_ERRORCODES_MAP.

310  {
311  *res = ICEDB_ERRORCODES_MAP[err];
312  }
ICEDB_SYMBOL_PRIVATE const char * ICEDB_ERRORCODES_MAP[ICEDB_ERRORCODES_TOTAL]
Definition: errorCodes.cpp:3

◆ stringify() [7/8]

DL_ICEDB void icedb::error::stringify ( const error_context_pt err,
std::string &  res 
)

Definition at line 313 of file error.cpp.

References ICEDB_error_context_to_message, and ICEDB_error_context_to_message_size.

313  {
314  // A few memory copies occur here. Inefficient, but errors should not occur much in properly running code.
315  size_t sz = ICEDB_error_context_to_message_size(err.get());
316  //std::unique_ptr<char[]> buf(new char[sz]);
317  std::vector<char> buf(sz);
318  ICEDB_error_context_to_message(err.get(), sz, buf.data());
319  res = std::string(buf.data());
320  }
DL_ICEDB ICEDB_error_context_to_message_f ICEDB_error_context_to_message
Definition: error.cpp:101
DL_ICEDB ICEDB_error_context_to_message_size_f ICEDB_error_context_to_message_size
Definition: error.cpp:61

◆ stringify() [8/8]

DL_ICEDB std::string icedb::error::stringify ( const error_context_pt err)

Definition at line 321 of file error.cpp.

References stringify().

321  {
322  std::string res;
323  stringify(err, res);
324  return res;
325  }
DL_ICEDB std::string stringify(const error_context_pt &err)
Definition: error.cpp:321
Here is the call graph for this function:

◆ stringify< const char * >()

template<>
DL_ICEDB const char* icedb::error::stringify< const char *> ( error_code_t  err)

Definition at line 298 of file error.cpp.

References ICEDB_ERRORCODES_MAP.

298  {
299  return ICEDB_ERRORCODES_MAP[err];
300  }
ICEDB_SYMBOL_PRIVATE const char * ICEDB_ERRORCODES_MAP[ICEDB_ERRORCODES_TOTAL]
Definition: errorCodes.cpp:3

◆ stringify< std::string >()

template<>
DL_ICEDB std::string icedb::error::stringify< std::string > ( error_code_t  err)

Definition at line 293 of file error.cpp.

References stringify().

293  {
294  std::string res;
295  stringify(err, res);
296  return res;
297  }
DL_ICEDB std::string stringify(const error_context_pt &err)
Definition: error.cpp:321
Here is the call graph for this function: