thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.2.1
ThePEG::Exception Class Reference

Exception is the base class for all exceptions to be used in ThePEG. More...

#include <Exception.h>

Inheritance diagram for ThePEG::Exception:

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. More...
 Exception ()
 Default constructor.
 Exception (const Exception &ex)
 The copy constructor.
virtual ~Exception () noexcept
 The destructor.
const Exceptionoperator= (const Exception &ex)
bool operator== (const Exception &ex) const
bool operator< (const Exception &ex) const
 Compare severity. More...
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 >
Exceptionoperator<< (const T &t)
 Add info to the exception message.
Exceptionoperator<< (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.

Detailed Description

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.

See also

Definition at line 44 of file Exception.h.

Member Enumeration Documentation

◆ Severity

The levels of severity.


Unknown severity.


Not severe (but the user should be informed).


Possibly severe, (the user should be warned).


Command failed during setup phase, execution is continued.


Possibly severe, (the event being generated should be discarded).


Severe error, (the run should be terminated).


Severe error, (the run should be terminated, possibly dumping core).


Severe error, (the run is aborted immediately, before the exception is thrown).

Definition at line 51 of file Exception.h.

Constructor & Destructor Documentation

◆ Exception()

ThePEG::Exception::Exception ( const string &  str,
Severity  sev 

Standard constructor.

stran error message.
sevthe severity.

Member Function Documentation

◆ operator<()

bool ThePEG::Exception::operator< ( const Exception ex) const

Compare severity.

If equal compare error message lexicographically.

Definition at line 123 of file Exception.h.

References message(), and severity().

The documentation for this class was generated from the following file: