Helper function to make it easier to throw exceptions. More...
|Standard constructor creating an internal Exception object. |
|template<typename T >|
|Throw &||operator<< (const T &t)|
|Add information to the current Exception object. |
|void||operator<< (Exception::Severity sev)|
|Specify the Exception::Severity of the exception. More...|
|The destructor will throw the exception if it has not been handled. |
|The ExceptionObject to be thrown. |
|If true, the exception has been handled and should not be thrown in the destructor. |
|Write warning messages to the current EventGenerator. More...|
Helper function to make it easier to throw exceptions.
The template argument should be a class inheriting from Exception. In the constructor, an object of this Exception class is created and afterwards a message may be added using ostream-like output (<<). If a Exception::Severity value is output with << the Exception object is assumed to be complete and the exception is actually thrown, except if the Exception::Severity value Exception::warning was specified, in which case the Exception object is treated as a warning which is logged with the current EventGenerator. If no current EventGenerator is present the warning message is instead written to std::cerr. If no Exception::Severity is specified, the Exception object is treated as a warning when the Throw object is destroyed.
Assuming you have an Exception class called MyEx the Throw class is used as follows:
Throw<MyEx>>() << "My error
message" << Exception::eventerror;
This will throw an exception and the current event will be discarded. Changing
Exception::warning will write out a warning, but no proper exception is thrown.
Specify the Exception::Severity of the exception.
Write warning messages to the current EventGenerator.
If no current EventGenerator is present, the warning message is instead written to std::cerr.