Template Class DataException

Inheritance Relationships

Base Type

Class Documentation

template<typename Data>
class DataException : public ecl::Exception

Extended exception class that bundles location, message and data.

This exception class extends the StandardException to include an additional component, a single data object. Usually its a good idea to keep the data object small - it is copied into the exception so that it cannot be lost if the original object should die.

The bundled data object must be streamable to standard output if this class is going to utilise the generic what() output.

See also

Exception, StandardException, Exceptions Guide.

Public Functions

DataException(const char *loc, ErrorFlag error, Data &d)

Default constructor for data exceptions.

Parameters:
  • loc – : use with the LOC macro, identifies the line and file of the code.

  • error – : enumerated exception error type.

  • d – : the data bundled with the exception.

DataException(const char *loc, ErrorFlag error, const std::string &msg, const Data &d)

Constructor for data exceptions with a custom message.

Parameters:
  • loc – : use with the LOC macro, identifies the line and file of the code.

  • error – : enumerated exception error type.

  • msg – : extra detail message.

  • d – : the data bundled with the exception.

DataException(const char *loc, const DataException<Data> &e)

Constructor for data exceptions that enables rethrowing of an existing exception up the heirarchy with a new code location stamp.

Parameters:
  • loc – : use with the LOC macro, identifies the line and file of the code.

  • e – : a caught standard exception that is to be rethrown.

inline virtual ~DataException()
virtual const char *what() const

Default exception handling output function.

Returns:

char const* : the output message.

inline const ErrorFlag &flag() const

Flag enumerating the type of exception thrown.

inline const Data &data() const

The bundled data object.