Class Error

Class Documentation

class Error

The primary error handler for ecl libraries.

This class is mostly used as the return type for ecl functions to indicate errors.

Error f(const int &i) {
   if ( i == 3 ) {
       return Error(NoError);
   else {
       return Error(OutOfRangeError);
   }
}

// code

Error error = f(5);
if ( error.flag() != NoError ) {
    std::cout << error.what() << std::endl; // OR
    error.print(LOC);   // for a verbose message with code location added.
}

Alternatively the class can be inherited and the verbose messages overloaded. Refer to the TimeError class in ecl_time_lite for an example.

Public Functions

inline explicit Error(const ErrorFlag &flag = UnknownError)

Configure the return type with an error flag.

Parameters:

flag – : the type of error that is to be returned.

inline virtual ~Error()
inline virtual ErrorFlag flag() const

The flag identifying the error identified with this error handler.

Returns:

ErrorFlag : the error flag

inline virtual void operator=(const ErrorFlag &error)
inline virtual bool operator==(const Error &other)

Comparison operator.

Returns:

bool : the result of the comparison

inline virtual void print(const char *loc)

Print a location dependent message to standard out.

Usage:

Error error = f(5);
if ( error.flag() != NoError ) {
    error.print(LOC);
}

Parameters:

loc – : use with the LOC macro.

inline virtual const char *what() const

A simple string verbosely representing the error that is handled.

Returns:

const char* : verbose representation of the error.

Protected Functions

inline virtual const char *noErrorString() const
inline virtual const char *outOfRangeErrorString() const
inline virtual const char *constructorErrorString() const
inline virtual const char *destructorErrorString() const
inline virtual const char *conversionErrorString() const
inline virtual const char *openErrorString() const
inline virtual const char *closeErrorString() const
inline virtual const char *invalidArgErrorString() const
inline virtual const char *configurationErrorString() const
inline virtual const char *connectErrorString() const
inline virtual const char *readErrorString() const
inline virtual const char *writeErrorString() const
inline virtual const char *notInitialisedErrorString() const
inline virtual const char *permissionsErrorString() const
inline virtual const char *memoryErrorString() const
inline virtual const char *usageErrorString() const
inline virtual const char *raiiErrorString() const
inline virtual const char *argNotSupportedErrorString() const
inline virtual const char *notSupportedErrorString() const
inline virtual const char *busyErrorString() const
inline virtual const char *outOfResourcesErrorString() const
inline virtual const char *interruptedErrorString() const
inline virtual const char *blockingErrorString() const
inline virtual const char *systemFailureErrorString() const
inline virtual const char *invalidObjectErrorString() const
inline virtual const char *isLockedErrorString() const
inline virtual const char *isTimeOutErrorString() const
inline virtual const char *notFoundErrorString() const
inline virtual const char *connectionRefusedString() const
inline virtual const char *unknownErrorString() const

Protected Attributes

ErrorFlag error_flag