#include <exception>
#include <stdexcept>
#include <string>
#include <iostream>
Go to the source code of this file.
Namespaces | |
namespace | dai |
Classes | |
class | dai::Exception |
Error handling in libDAI is done by throwing an instance of the Exception class. More... | |
Defines | |
#define | DAI_QUOTE(x) #x |
Used by DAI_THROW. | |
#define | DAI_TOSTRING(x) DAI_QUOTE(x) |
Used by DAI_THROW. | |
#define | DAI_THROW(cod) throw dai::Exception(dai::Exception::cod, std::string(__FILE__ ", line " DAI_TOSTRING(__LINE__))) |
Macro that simplifies throwing an exception with a useful default error message. | |
#define | DAI_THROWE(cod, msg) throw dai::Exception(dai::Exception::cod, std::string(__FILE__ ", line " DAI_TOSTRING(__LINE__)), msg) |
Macro that simplifies throwing an exception with a user-defined error message. | |
#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. |
#define DAI_QUOTE | ( | x | ) | #x |
Used by DAI_THROW.
#define DAI_TOSTRING | ( | x | ) | DAI_QUOTE(x) |
Used by DAI_THROW.
#define DAI_THROW | ( | cod | ) | throw dai::Exception(dai::Exception::cod, std::string(__FILE__ ", line " DAI_TOSTRING(__LINE__))) |
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 |
DAI_THROW(NOT_IMPLEMENTED);
#define DAI_THROWE | ( | cod, | |||
msg | ) | throw dai::Exception(dai::Exception::cod, std::string(__FILE__ ", line " 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. |
DAI_THROWE(NOT_IMPLEMENTED,"Detailed error message");
#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.