thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
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.
 
 Exception ()
 Default constructor.
 
 Exception (const Exception &ex)
 The copy constructor.
 
virtual ~Exception () noexcept
 The destructor.
 
const Exceptionoperator= (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 >
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
Repository
EventGenrator

Definition at line 44 of file Exception.h.

Member Enumeration Documentation

◆ Severity

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.

Constructor & Destructor Documentation

◆ Exception() [1/3]

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

Standard constructor.

Parameters
stran error message.
sevthe severity.

◆ Exception() [2/3]

ThePEG::Exception::Exception ( )
inline

Default constructor.

Definition at line 82 of file Exception.h.

◆ Exception() [3/3]

ThePEG::Exception::Exception ( const Exception ex)
inline

The copy constructor.

Definition at line 87 of file Exception.h.

References handle().

Member Function Documentation

◆ handle()

void ThePEG::Exception::handle ( ) const
inline

Indicate that this exception has been taken care of.

Definition at line 161 of file Exception.h.

References handled.

Referenced by Exception().

◆ message()

string ThePEG::Exception::message ( ) const
inline

Return the error message.

Definition at line 143 of file Exception.h.

References theMessage.

Referenced by operator<(), operator==(), and what().

◆ operator<()

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().

◆ operator<<() [1/2]

template<typename T >
Exception & ThePEG::Exception::operator<< ( const T &  t)
inline

Add info to the exception message.

Definition at line 167 of file Exception.h.

References theMessage.

◆ operator<<() [2/2]

Exception & ThePEG::Exception::operator<< ( Severity  sev)
inline

Set the severity for the exception.

Definition at line 175 of file Exception.h.

References severity().

◆ operator=()

const Exception & ThePEG::Exception::operator= ( const Exception ex)
inline

Assignment.

Definition at line 104 of file Exception.h.

References handled, theMessage, and theSeverity.

◆ operator==()

bool ThePEG::Exception::operator== ( const Exception ex) const
inline

Comparison.

Definition at line 115 of file Exception.h.

References message(), and severity().

◆ severity()

Severity ThePEG::Exception::severity ( ) const
inline

Return the severity.

Definition at line 156 of file Exception.h.

References theSeverity.

Referenced by operator<(), operator<<(), and operator==().

◆ what()

virtual const char * ThePEG::Exception::what ( ) const
inlinevirtualnoexcept

Return the error message.

Definition at line 134 of file Exception.h.

References message().

Member Data Documentation

◆ errstream

ostream* ThePEG::Exception::errstream
staticprivate

The default stream to write the error message if unhandled.

Definition at line 207 of file Exception.h.

◆ handled

bool ThePEG::Exception::handled
mutableprivate

True if this exception has been taken care of.

Definition at line 197 of file Exception.h.

Referenced by handle(), and operator=().

◆ noabort

bool ThePEG::Exception::noabort
static

If this flag is set, all abortnow and maybeabort severities will be treated as runerror.

Definition at line 215 of file Exception.h.

◆ theMessage

ostringstream ThePEG::Exception::theMessage
mutableprotected

Stream to write the error message to.

Definition at line 190 of file Exception.h.

Referenced by message(), operator<<(), and operator=().

◆ theSeverity

Severity ThePEG::Exception::theSeverity
private

The severity.

Definition at line 202 of file Exception.h.

Referenced by operator=(), and severity().


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