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 () noexcept |
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 noexcept |
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. | |
Static Public Attributes | |
static bool | noabort |
If this flag is set, all abortnow and maybeabort severities will be treated as runerror. | |
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
.
Definition at line 44 of file Exception.h.
The levels of severity.
Enumerator | |
---|---|
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. |
|
inline |
Default constructor.
Definition at line 82 of file Exception.h.
|
inline |
|
inline |
Indicate that this exception has been taken care of.
Definition at line 161 of file Exception.h.
References handled.
Referenced by Exception().
|
inline |
Return the error message.
Definition at line 143 of file Exception.h.
References theMessage.
Referenced by operator<(), operator==(), and what().
|
inline |
Compare severity.
If equal compare error message lexicographically.
Definition at line 123 of file Exception.h.
References message(), and severity().
|
inline |
Add info to the exception message.
Definition at line 167 of file Exception.h.
References theMessage.
Set the severity for the exception.
Definition at line 175 of file Exception.h.
References severity().
Assignment.
Definition at line 104 of file Exception.h.
References handled, theMessage, and theSeverity.
|
inline |
|
inline |
Return the severity.
Definition at line 156 of file Exception.h.
References theSeverity.
Referenced by operator<(), operator<<(), and operator==().
|
inlinevirtualnoexcept |
|
staticprivate |
The default stream to write the error message if unhandled.
Definition at line 207 of file Exception.h.
|
mutableprivate |
True if this exception has been taken care of.
Definition at line 197 of file Exception.h.
Referenced by handle(), and operator=().
|
static |
If this flag is set, all abortnow and maybeabort severities will be treated as runerror.
Definition at line 215 of file Exception.h.
|
mutableprotected |
Stream to write the error message to.
Definition at line 190 of file Exception.h.
Referenced by message(), operator<<(), and operator=().
|
private |
The severity.
Definition at line 202 of file Exception.h.
Referenced by operator=(), and severity().