DynExp
Highly flexible laboratory automation for dynamically changing experiments.
Util::Exception Class Reference

DynExp exceptions are derived from this class. It contains basic information about the cause of the exception as well as a stacktrace. More...

+ Inheritance diagram for Util::Exception:

Public Member Functions

 Exception (std::string Description, const ErrorType Type=ErrorType::Error, const int ErrorCode=-1, const std::source_location Location=std::source_location::current()) noexcept
 Constructs an exception. Constructor is noexcept, although std::runtime_error() might throw std::bad_alloc issuing a call to std::terminate(), which might be the best solution in that case. More...
 
virtual ~Exception ()=default
 
constexpr const char * GetErrorLabel () const
 
constexpr const char * GetErrorLabelColor () const
 

Static Public Member Functions

constexpr static const char * GetErrorLabel (const ErrorType Type)
 Converts an error type to a user-readable label for logging. More...
 
constexpr static const char * GetErrorLabelColor (const ErrorType Type)
 Converts an error type to an HTML color name for logging. More...
 

Public Attributes

const ErrorType Type
 DynExp error type from Util::ErrorType More...
 
const int ErrorCode
 DynExp error code from DynExpErrorCodes::DynExpErrorCodes More...
 
const size_t Line
 Line in source code where the exception occurred. More...
 
const std::string Function
 Function in source code where the exception occurred
More...
 
const std::string File
 Source code file where the exception occurred. More...
 

Detailed Description

DynExp exceptions are derived from this class. It contains basic information about the cause of the exception as well as a stacktrace.

Definition at line 50 of file Exception.h.

Constructor & Destructor Documentation

◆ Exception()

Util::Exception::Exception ( std::string  Description,
const ErrorType  Type = ErrorType::Error,
const int  ErrorCode = -1,
const std::source_location  Location = std::source_location::current() 
)
noexcept

Constructs an exception. Constructor is noexcept, although std::runtime_error() might throw std::bad_alloc issuing a call to std::terminate(), which might be the best solution in that case.

Parameters
DescriptionDescription explaining the cause of the exception in detail for the user.
TypeError type from Util::ErrorType
ErrorCodeError code from DynExpErrorCodes
LocationUsed to derive the origin of the exception. Pass the result of std::source_location::current() as called by the constructor of the derived classes.

Definition at line 8 of file Exception.cpp.

◆ ~Exception()

virtual Util::Exception::~Exception ( )
virtualdefault

Member Function Documentation

◆ GetErrorLabel() [1/2]

constexpr const char* Util::Exception::GetErrorLabel ( ) const
inlineconstexpr

Definition at line 98 of file Exception.h.

◆ GetErrorLabel() [2/2]

constexpr static const char* Util::Exception::GetErrorLabel ( const ErrorType  Type)
inlinestaticconstexpr

Converts an error type to a user-readable label for logging.

Parameters
TypeError type from Util::ErrorType
Returns
String describing the error type

Definition at line 71 of file Exception.h.

◆ GetErrorLabelColor() [1/2]

constexpr const char* Util::Exception::GetErrorLabelColor ( ) const
inlineconstexpr

Definition at line 99 of file Exception.h.

◆ GetErrorLabelColor() [2/2]

constexpr static const char* Util::Exception::GetErrorLabelColor ( const ErrorType  Type)
inlinestaticconstexpr

Converts an error type to an HTML color name for logging.

Parameters
TypeError type from Util::ErrorType
Returns
HTML color name matching the error type

Definition at line 87 of file Exception.h.

Member Data Documentation

◆ ErrorCode

const int Util::Exception::ErrorCode

DynExp error code from DynExpErrorCodes::DynExpErrorCodes

Definition at line 106 of file Exception.h.

◆ File

const std::string Util::Exception::File

Source code file where the exception occurred.

Definition at line 109 of file Exception.h.

◆ Function

const std::string Util::Exception::Function

Function in source code where the exception occurred

Definition at line 108 of file Exception.h.

◆ Line

const size_t Util::Exception::Line

Line in source code where the exception occurred.

Definition at line 107 of file Exception.h.

◆ Type

const ErrorType Util::Exception::Type

DynExp error type from Util::ErrorType

Definition at line 105 of file Exception.h.


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