#include <Throw.h>
Public Member Functions | |
Throw () | |
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. | |
~Throw () | |
The destructor will throw the exception if it has not been handled. | |
Public Attributes | |
Ex | ex |
The ExceptionObject to be thrown. | |
bool | handled |
If true, the exception has been handled and should not be thrown in the destructor. |
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 thrown 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::eventerror
to Exception::warning
will write out a warning, but no proper exception is thrown.
Definition at line 44 of file Throw.h.
void ThePEG::Throw< Ex >::operator<< | ( | Exception::Severity | sev | ) | [inline] |
Specify the Exception::Severity of the exception.
If this is Exception::warning, the exception will not be thown, instead it will be logged with the current * EventGenerator. If no current EventGenerator is present the warning * message is instead written to std::cerr. All other seveities will cause the exception to be thrown immediately.
Definition at line 67 of file Throw.h.
References ThePEG::BaseRepository::clog(), ThePEG::CurrentGenerator::current(), ThePEG::Throw< Ex >::ex, ThePEG::Throw< Ex >::handled, ThePEG::Exception::info, ThePEG::CurrentGenerator::isVoid(), ThePEG::EventGenerator::logWarning(), and ThePEG::Exception::warning.