Elements 6.3.1
A C++ base framework for the Euclid Software.
Loading...
Searching...
No Matches

Elements base exception class. More...

#include <Exception.h>

Inheritance diagram for Elements::Exception:
Collaboration diagram for Elements::Exception:

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 *string_format, Args &&... args)
 Constructs a new Exception with a message using format specifiers.
 
 Exception (const Exception &rhs)=default
 
virtual ~Exception () noexcept
 
const char * what () const noexcept override
 
ExitCode exitCode () const noexcept
 
template<typename T >
void appendMessage (const T &message)
 Appends in the end of the exception message the parameter.
 
- Public Member Functions inherited from std::exception
what (T... args)
 
~exception (T... args)
 
operator= (T... args)
 
exception (T... args)
 

Protected Attributes

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

Detailed Description

Elements base exception class.

Definition at line 44 of file Exception.h.

Constructor & Destructor Documentation

◆ Exception() [1/5]

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

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

Parameters
ethis is an optional exit code. By default is is set to NOT_OK.

Definition at line 27 of file Exception.cpp.

◆ Exception() [2/5]

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

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.
ethis is an optional exit code. By default is is set to NOT_OK.

Definition at line 29 of file Exception.cpp.

◆ Exception() [3/5]

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

Constructor (C++ STL strings).

Parameters
messageThe error message.
ethis is an optional exit code. By default is is set to NOT_OK.

Definition at line 31 of file Exception.cpp.

◆ Exception() [4/5]

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

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

◆ Exception() [5/5]

Elements::Exception::Exception ( const Exception & rhs)
default

Explicit default copy constructor

◆ ~Exception()

Elements::Exception::~Exception ( )
virtualdefaultnoexcept

Virtual destructor.

Member Function Documentation

◆ appendMessage()

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

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

◆ exitCode()

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

Return the exit code of the Exception

Returns
the exit code

Definition at line 39 of file Exception.cpp.

References m_exit_code.

Referenced by Elements::ProgramManager::onTerminate().

◆ what()

const char * Elements::Exception::what ( ) const
overridenoexcept

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 35 of file Exception.cpp.

Referenced by Elements::ProgramManager::onTerminate().

Member Data Documentation

◆ m_error_msg

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

Error message.

Definition at line 119 of file Exception.h.

◆ m_exit_code

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

Definition at line 120 of file Exception.h.

Referenced by exitCode().


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