libDAI
|
Defines the Exception class and macros for throwing exceptions and doing assertions. More...
#include <exception>
#include <stdexcept>
#include <string>
#include <iostream>
Go to the source code of this file.
Classes | |
class | dai::Exception |
Error handling in libDAI is done by throwing an instance of the Exception class. More... | |
Namespaces | |
dai | |
Namespace for libDAI. | |
Macros | |
#define | DAI_QUOTE(x) #x |
Used by DAI_THROW. More... | |
#define | DAI_TOSTRING(x) DAI_QUOTE(x) |
Used by DAI_THROW. More... | |
#define | FUNCTION_NAME __func__ |
Macro that simplifies throwing an exception with a useful default error message. More... | |
#define | DAI_THROW(cod) throw dai::Exception(dai::Exception::cod, __FILE__, FUNCTION_NAME, DAI_TOSTRING(__LINE__), "") |
#define | DAI_THROWE(cod, msg) throw dai::Exception(dai::Exception::cod, __FILE__, FUNCTION_NAME, DAI_TOSTRING(__LINE__), msg) |
Macro that simplifies throwing an exception with a user-defined error message. More... | |
#define | DAI_ASSERT(condition) ((condition) ? ((void)0) : DAI_THROWE(ASSERTION_FAILED, std::string("Assertion \"" #condition "\" failed"))) |
Assertion mechanism, similar to the standard assert() macro. It is always active, even if NDEBUG is defined. More... | |
#define | DAI_DEBASSERT(x) do {DAI_ASSERT(x);} while(0) |
Assertion mechanism similar to DAI_ASSERT which is only active if DAI_DEBUG is defined. More... | |
Defines the Exception class and macros for throwing exceptions and doing assertions.
#define DAI_QUOTE | ( | x | ) | #x |
Used by DAI_THROW.
#define DAI_TOSTRING | ( | x | ) | DAI_QUOTE(x) |
Used by DAI_THROW.
#define FUNCTION_NAME __func__ |
Macro that simplifies throwing an exception with a useful default error message.
The error message consists of a description of the exception, the source code file and line number where the exception has been thrown.
cod | Corresponds to one of the enum values of dai::Exception::Code |
#define DAI_THROWE | ( | cod, | |
msg | |||
) | throw dai::Exception(dai::Exception::cod, __FILE__, FUNCTION_NAME, DAI_TOSTRING(__LINE__), msg) |
Macro that simplifies throwing an exception with a user-defined error message.
cod | Corresponds to one of the enum values of dai::Exception::Code |
msg | Detailed error message that will be written to std::cerr. |
#define DAI_ASSERT | ( | condition | ) | ((condition) ? ((void)0) : DAI_THROWE(ASSERTION_FAILED, std::string("Assertion \"" #condition "\" failed"))) |
Assertion mechanism, similar to the standard assert() macro. It is always active, even if NDEBUG is defined.
#define DAI_DEBASSERT | ( | x | ) | do {DAI_ASSERT(x);} while(0) |
Assertion mechanism similar to DAI_ASSERT which is only active if DAI_DEBUG is defined.