Elements  5.8
A C++ base framework for the Euclid Software.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Classes | Public Member Functions | Public Attributes | Protected Attributes | List of all members
Elements::Exception Class Reference

#include <Exception.h>

Inheritance diagram for Elements::Exception:
[legend]
Collaboration diagram for Elements::Exception:
[legend]

Classes

struct  ExitCodeHelper
 
struct  ExitCodeHelper< First, Rest...>
 
struct  ExitCodeHelper< Last >
 

Public Member Functions

 Exception (ExitCode e=ExitCode::NOT_OK)
 
 Exception (const char *message, ExitCode e=ExitCode::NOT_OK)
 
 Exception (const std::string &message, ExitCode e=ExitCode::NOT_OK)
 
template<typename... Args>
 Exception (const char *stringFormat, Args &&...args)
 Constructs a new Exception with a message using format specifiers. More...
 
 snprintf (message, len, stringFormat, std::forward< Args >(args)...)
 
virtual ~Exception () noexcept=default
 
const char * what () const noexceptoverride
 
ExitCode exitCode () const noexcept
 
template<typename T >
void appendMessage (const T &message)
 Appends in the end of the exception message the parameter. More...
 
- Public Member Functions inherited from std::exception
what (T...args)
 
~exception (T...args)
 
operator= (T...args)
 
exception (T...args)
 

Public Attributes

 code
 
char * message = new char[len]
 
 m_error_msg = std::string {message}
 
delete[] message
 

Protected Attributes

std::string m_error_msg {}
 
const ExitCode m_exit_code {ExitCode::NOT_OK}
 

Detailed Description

Definition at line 41 of file Exception.h.

Constructor & Destructor Documentation

Elements::Exception::Exception ( ExitCode  e = ExitCode::NOT_OK)
inlineexplicit

Default constructor. The message is set to the empty string.

Parameters
e,:this is an optional exit code. By default is is set to NOT_OK.

Definition at line 48 of file Exception.h.

References Elements::Units::e.

Elements::Exception::Exception ( const char *  message,
ExitCode  e = ExitCode::NOT_OK 
)
inlineexplicit

Constructor (C strings).

Parameters
messageC-style string error message. The string contents are copied upon construction. Hence, responsibility for deleting the char* lies with the caller.
e,:this is an optional exit code. By default is is set to NOT_OK.

Definition at line 60 of file Exception.h.

References Elements::Units::e.

Elements::Exception::Exception ( const std::string message,
ExitCode  e = ExitCode::NOT_OK 
)
inlineexplicit

Constructor (C++ STL strings).

Parameters
messageThe error message.
e,:this is an optional exit code. By default is is set to NOT_OK.

Definition at line 69 of file Exception.h.

References Elements::Units::e.

template<typename... Args>
Elements::Exception::Exception ( const char *  stringFormat,
Args &&...  args 
)
inlineexplicit

Constructs a new Exception with a message using format specifiers.

Parameters
stringFormatThe message containing the format specifiers
argsThe values to replace the format specifiers with

Definition at line 80 of file Exception.h.

virtual Elements::Exception::~Exception ( )
virtualdefaultnoexcept

Virtual destructor.

Member Function Documentation

template<typename T >
void Elements::Exception::appendMessage ( const T &  message)
inline

Appends in the end of the exception message the parameter.

The passed parameters can be of any type the << operator of the std::stringstream can handle.

Parameters
messageThe message to append

Definition at line 118 of file Exception.h.

References std::stringstream::str().

Here is the call graph for this function:

ExitCode Elements::Exception::exitCode ( ) const
inlinenoexcept

Return the exit code of the Exception

Returns
the exit code

Definition at line 106 of file Exception.h.

Referenced by Elements::ProgramManager::onTerminate(), and Elements::ProgramManager::setup().

Elements::Exception::snprintf ( message  ,
len  ,
stringFormat  ,
std::forward< Args >(args)  ... 
)
const char* Elements::Exception::what ( ) const
inlineoverridenoexcept

Returns a pointer to the (constant) error description.

Returns
A pointer to a const char *. The underlying memory is in possession of the Exception object. Callers must not attempt to free the memory.

Definition at line 98 of file Exception.h.

Referenced by Elements::ProgramManager::onTerminate(), and Elements::ProgramManager::setup().

Member Data Documentation

Elements::Exception::code
Initial value:
{
size_t len = snprintf(NULL, 0, stringFormat, std::forward<Args>(args)...)+1

Definition at line 81 of file Exception.h.

Elements::Exception::m_error_msg = std::string {message}

Definition at line 85 of file Exception.h.

std::string Elements::Exception::m_error_msg {}
protected

Error message.

Definition at line 127 of file Exception.h.

const ExitCode Elements::Exception::m_exit_code {ExitCode::NOT_OK}
protected

Definition at line 128 of file Exception.h.

char* Elements::Exception::message = new char[len]

Definition at line 83 of file Exception.h.

delete [] Elements::Exception::message

Definition at line 86 of file Exception.h.


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