Bayeux
3.4.1
Core Foundation library for SuperNEMO
|
Utility macros for exception handling. More...
#include <stdexcept>
#include <sstream>
#include <boost/current_function.hpp>
Go to the source code of this file.
Macros | |
#define | DT_THROW_IF(Condition, ExceptionType, Message) |
#define | DT_THROW(ExceptionType, Message) |
Utility macros for exception handling.
Exceptions are often thrown based on the value of a boolean expression. The exception, if it holds a string based message about what went wrong, should report where it was thrown from.
To help developers throwing exceptions in this fashion, datatools supplies some macros to assist in simplifying this work, and making the intent clearer in code.
#define DT_THROW | ( | ExceptionType, | |
Message | |||
) |
Throw ExceptionType with Message This macro is intended to simplify the common use case of throwing exceptions, with the exception holding a string message indicating where and why the exception was thrown. This macro takes two arguments as follows
ExceptionType | Typename of object to throw, the type must take a string as its constructor argument |
Message | Message to supply to ExceptionType, this must take the form of a string or output stream sequence |
The Message is formatted as
where SIGNATURE is the signature of the function from which the exception is thrown, and LINENUMBER is the line number where the throw occured.
In the simplest case it may be used as
If Message is composed from several streamable objects, it can be composed using the streaming operator:
#define DT_THROW_IF | ( | Condition, | |
ExceptionType, | |||
Message | |||
) |
Throw ExceptionType with Message if the expression Condition is true This macro is intended to simplify the common use case of throwing exceptions when a boolean condition is true, with the exception holding a string message indicating where and why the exception was thrown. This macro takes three arguments as follows
Condition | Boolean expression |
ExceptionType | Typename of object to throw, the type must take a string as its constructor argument |
Message | Message to supply to ExceptionType, this must take the form of a string or output stream sequence |
The Message is formatted as
where SIGNATURE is the signature of the function from which the exception is thrown, and LINENUMBER is the line number where the throw occured.
In the simplest case it may be used as
If Message is composed from several streamable objects, it can be composed using the streaming operator: