Public Member Functions

Exception Class Reference

Base protocol class for all exceptions. More...

#include <keyvalue/sys/exception/Exception.h>

Inheritance diagram for Exception:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 Exception ()
 Constructor (of course!).
virtual const char * what () const =0
 Gets an explanatory C string message about the exception.
virtual const MessagegetMessage () const =0
 Gets the inner Message object stored by the exception.

Detailed Description

Base protocol class for all exceptions.


Constructor & Destructor Documentation

Exception (  ) 

Constructor (of course!).

Tip: Since all KeyValue exceptions are derived from this class, whenever an exception is created, this constructor is called. Hence, when debugging, if you wish to trace a thrown exception, then place a breakpoint inside the constructor and take a look at the call stack.


Member Function Documentation

virtual const char* what (  )  const [pure virtual]

Gets an explanatory C string message about the exception.

This methods exists for compatibility with std::exception::what(). Through a pointer or reference to either Exception or std::exception it is possible to get the same explanatory message.

By maintaining compatibility with std::exception::what(), KeyValue exceptions can be catch by many already implemented exception handlers. However, it is preferable to use KeyValue's exception management. In particular the method getMessage() is a better alternative to this one.

Returns:
A C null terminated char string with a explanatory message about the exception.

Implemented in ExceptionImpl< StdExcept, MessageType >.

virtual const Message& getMessage (  )  const [pure virtual]

Gets the inner Message object stored by the exception.

Recall that Message objects carry more than just an explanatory text about the exception. It also contains extra information like its prefix and colour, which allows a nicer presentation by a logger::Logger.

Returns:
The inner Message object.

Implemented in ExceptionImpl< StdExcept, MessageType >.