Exception
is the base class for all exceptions to be used in ThePEG.
More...
#include <Exception.h>
Public Types | |
enum | Severity { unknown, info, warning, setuperror, eventerror, runerror, maybeabort, abortnow } |
The levels of severity. More... | |
Public Member Functions | |
Exception (const string &str, Severity sev) | |
Standard constructor. | |
Exception () | |
Default constructor. | |
Exception (const Exception &ex) | |
The copy constructor. | |
virtual | ~Exception () throw () |
The destructor. | |
const Exception & | operator= (const Exception &ex) |
Assignment. | |
bool | operator== (const Exception &ex) const |
Comparison. | |
bool | operator< (const Exception &ex) const |
Compare severity. | |
virtual const char * | what () const throw () |
Return the error message. | |
string | message () const |
Return the error message. | |
void | writeMessage (ostream &os=*errstream) const |
Write the error message to a stream. | |
Severity | severity () const |
Return the severity. | |
void | handle () const |
Indicate that this exception has been taken care of. | |
template<typename T> | |
Exception & | operator<< (const T &t) |
Add info to the exception message. | |
Exception & | operator<< (Severity sev) |
Set the severity for the exception. | |
Protected Member Functions | |
void | severity (Severity) |
set the severity. | |
Protected Attributes | |
ostringstream | theMessage |
Stream to write the error message to. | |
Private Attributes | |
bool | handled |
True if this exception has been taken care of. | |
Severity | theSeverity |
The severity. | |
Static Private Attributes | |
static ostream * | errstream |
The default stream to write the error message if unhandled. |
Exception
is the base class for all exceptions to be used in ThePEG.
It is derived from std::exception
and adds information about the severity of the exception to indicate to the Repository and EventGenrator how to act on it.
To throw an exception one should inherit from Exception
and add information in the constructor of the base class. Alternatively one can use the operator<<
operator on a default constructed Exception
to add information as for a standard ostream
object, in which case one should always end with adding an enum of the type Exception::Severity
to indicate the severity of the exception e.g.
Exception() << "Something went wrong." << Exception::eventerror
.
EventGenrator
Definition at line 44 of file Exception.h.
The levels of severity.
unknown | Unknown severity. |
info |
Not severe (but the user should be informed).
|
warning |
Possibly severe, (the user should be warned).
|
setuperror |
Command failed during setup phase, execution is continued.
|
eventerror |
Possibly severe, (the event being generated should be discarded).
|
runerror |
Severe error, (the run should be terminated).
|
maybeabort |
Severe error, (the run should be terminated, possibly dumping core).
|
abortnow |
Severe error, (the run is aborted immediately, before the exception is thrown).
|
Definition at line 51 of file Exception.h.
ThePEG::Exception::Exception | ( | const string & | str, | |
Severity | sev | |||
) |
Standard constructor.
str | an error message. | |
sev | the severity. |
bool ThePEG::Exception::operator< | ( | const Exception & | ex | ) | const [inline] |
Compare severity.
If equal compare error message lexicographically.
Definition at line 123 of file Exception.h.
References message(), and severity().