LDMX Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
framework::exception::Exception Class Reference

Standard base exception class with some useful output information. More...

#include <Exception.h>

Public Member Functions

 Exception () throw ()
 Empty constructor.
 
 Exception (const std::string &name, const std::string &message, const std::string &module, int line, const std::string &function)
 Class constructor.
 
virtual ~Exception () throw ()
 Class destructor.
 
const std::string & name () const throw ()
 Get the name of the exception.
 
const std::string & message () const throw ()
 Get the message of the exception.
 
const std::string & module () const throw ()
 Get the source filename where the exception occurred.
 
const std::string & function () const throw ()
 Get the function name where the exception occurred.
 
int line () const throw ()
 Get the source line number where the exception occurred.
 
virtual const char * what () const throw ()
 The error message.
 
const std::string & stackTrace () const throw ()
 Get the full stack trace.
 

Private Member Functions

void buildStackTrace () throw ()
 

Private Attributes

std::string name_
 Exception name.
 
std::string message_
 Error message.
 
std::string module_
 Source filename where the exception occurred.
 
std::string function_
 Function name where the exception occurred.
 
int line_ {0}
 Source line number where the exception occurred.
 
std::string stackTrace_
 The stack trace.
 

Detailed Description

Standard base exception class with some useful output information.

Note
It is strongly recommended to use the EXCEPTION_RAISE macro to throw exceptions.

Definition at line 20 of file Exception.h.

Constructor & Destructor Documentation

◆ Exception() [1/2]

framework::exception::Exception::Exception ( )
throw (
)
inline

Empty constructor.

Don't build stack trace for empty exceptions.

Definition at line 27 of file Exception.h.

27{}

◆ Exception() [2/2]

framework::exception::Exception::Exception ( const std::string &  name,
const std::string &  message,
const std::string &  module,
int  line,
const std::string &  function 
)
inline

Class constructor.

Parameters
nameName of the exception.
messageExtended message describing the exception.
moduleFilename in the source code where the exception occurred.
lineLine in the source code where the exception occurred.
functionFunction in which the exception occurred.

Definition at line 37 of file Exception.h.

39 : name_{name},
41 module_{module},
42 function_{function},
43 line_{line} {
44 buildStackTrace();
45 }
const std::string & message() const
Get the message of the exception.
Definition Exception.h:62
const std::string & name() const
Get the name of the exception.
Definition Exception.h:56
std::string module_
Source filename where the exception occurred.
Definition Exception.h:103
std::string message_
Error message.
Definition Exception.h:100
std::string name_
Exception name.
Definition Exception.h:97

◆ ~Exception()

virtual framework::exception::Exception::~Exception ( )
throw (
)
inlinevirtual

Class destructor.

Definition at line 50 of file Exception.h.

50{}

Member Function Documentation

◆ buildStackTrace()

void framework::exception::Exception::buildStackTrace ( )
throw (
)
private

Definition at line 156 of file Exception.cxx.

156{ stackTrace_ = Backtrace(2); }
std::string stackTrace_
The stack trace.
Definition Exception.h:112

◆ function()

const std::string & framework::exception::Exception::function ( ) const
throw (
)
inline

Get the function name where the exception occurred.

Returns
The function name where the exception occurred.

Definition at line 74 of file Exception.h.

74{ return function_; }
std::string function_
Function name where the exception occurred.
Definition Exception.h:106

References function_.

Referenced by eventdisplay::Display::draw(), and eventdisplay::Display::SetFile().

◆ line()

int framework::exception::Exception::line ( ) const
throw (
)
inline

Get the source line number where the exception occurred.

Returns
The source line number where the exception occurred.

Definition at line 80 of file Exception.h.

80{ return line_; }
int line_
Source line number where the exception occurred.
Definition Exception.h:109

References line_.

Referenced by eventdisplay::Display::draw(), and eventdisplay::Display::SetFile().

◆ message()

const std::string & framework::exception::Exception::message ( ) const
throw (
)
inline

Get the message of the exception.

Returns
The message of the exception.

Definition at line 62 of file Exception.h.

62{ return message_; }

References message_.

Referenced by eventdisplay::Display::draw(), and eventdisplay::Display::SetFile().

◆ module()

const std::string & framework::exception::Exception::module ( ) const
throw (
)
inline

Get the source filename where the exception occurred.

Returns
The source filename where the exception occurred.

Definition at line 68 of file Exception.h.

68{ return module_; }

References module_.

Referenced by eventdisplay::Display::draw(), and eventdisplay::Display::SetFile().

◆ name()

const std::string & framework::exception::Exception::name ( ) const
throw (
)
inline

Get the name of the exception.

Returns
The name of the exception.

Definition at line 56 of file Exception.h.

56{ return name_; }

References name_.

Referenced by eventdisplay::Display::draw(), and eventdisplay::Display::SetFile().

◆ stackTrace()

const std::string & framework::exception::Exception::stackTrace ( ) const
throw (
)
inline

Get the full stack trace.

Definition at line 91 of file Exception.h.

91{ return stackTrace_; }

References stackTrace_.

Referenced by eventdisplay::Display::SetFile().

◆ what()

virtual const char * framework::exception::Exception::what ( ) const
throw (
)
inlinevirtual

The error message.

Returns
The error message.

Definition at line 86 of file Exception.h.

86{ return message_.c_str(); }

References message_.

Member Data Documentation

◆ function_

std::string framework::exception::Exception::function_
private

Function name where the exception occurred.

Definition at line 106 of file Exception.h.

Referenced by function().

◆ line_

int framework::exception::Exception::line_ {0}
private

Source line number where the exception occurred.

Definition at line 109 of file Exception.h.

109{0};

Referenced by line().

◆ message_

std::string framework::exception::Exception::message_
private

Error message.

Definition at line 100 of file Exception.h.

Referenced by message(), and what().

◆ module_

std::string framework::exception::Exception::module_
private

Source filename where the exception occurred.

Definition at line 103 of file Exception.h.

Referenced by module().

◆ name_

std::string framework::exception::Exception::name_
private

Exception name.

Definition at line 97 of file Exception.h.

Referenced by name().

◆ stackTrace_

std::string framework::exception::Exception::stackTrace_
private

The stack trace.

Definition at line 112 of file Exception.h.

Referenced by stackTrace().


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