Base protocol class
for all exceptions.
More...
#include <keyvalue/sys/exception/Exception.h>
Public Member Functions | |
Exception () | |
Constructor (of course!). | |
virtual const char * | what () const =0 |
Gets an explanatory C string message about the exception. | |
virtual const Message & | getMessage () const =0 |
Gets the inner Message object stored by the exception. |
Base protocol class
for all exceptions.
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.
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.
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 color, which allows a nicer presentation by a logger::Logger.
Implemented in ExceptionImpl< StdExcept, MessageType >.