rad 6.2.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
rad::Exception Class Reference

Base class for the exceptions thrown by RAD and its users. More...

#include <exceptions.hpp>

Inheritance diagram for rad::Exception:

Public Types

typedef std::chrono::system_clock ClockT
 The clock to use for determining the exception creation time.
 

Public Member Functions

 Exception (const std::string &message)
 Constructor.
 
 Exception (const std::string &message, const std::string &info)
 
virtual ~Exception ()=default
 Destructor.
 
const boost::stacktrace::stacktrace & GetStackTrace () const
 Return the stack trace captured in the exception constructor.
 
const boost::stacktrace::stacktrace & GetOriginalStackTrace () const
 Return the stack trace captured in the most nested exception constructor.
 
std::string GetStackTraceAsString () const
 Same as GetStackTrace() but convert the trace to a string.
 
std::string GetOriginalStackTraceAsString () const
 Same as GetOriginalStackTrace() but convert the trace to a string.
 
std::string GetFullStackTraceAsString () const
 Return the full stack trace (including nested exceptions)
 
std::chrono::time_point< ClockTGetTimePoint () const
 Return the exception creation time as a chrono timepoint.
 
int64_t GetCreationDate () const
 Return the exception creation time as number of seconds since Unix Epoch.
 
std::thread::id GetThreadId () const
 Return the id of the thread in which the exception was created.
 
int GetProcessId () const
 Return the id of the process in which the exception was created.
 
std::string GetHostName () const
 Return the name of the host in which the exception was created.
 
std::string GetTypeName () const
 Return the exception class name.
 
void SetLineNumber (uint32_t line_number)
 Set the line number in which the exception was thrown.
 
uint32_t GetLineNumber () const
 Return the line number in which the exception was thrown.
 
void SetFunctionName (const std::string &function_name)
 Set the name of the function in which the exception was thrown.
 
const std::string & GetFunctionName () const
 Return the name of the function in which the exception was thrown.
 
void SetFileName (const std::string &file_name)
 Set the name of the file in which the exception was thrown.
 
const std::string & GetFileName () const
 Return the name of the file in which the exception was thrown.
 
void SetDetails (const std::string &details)
 Set the exception details.
 
std::string GetDetails () const
 Get the exception details.
 
void SetClassName (const std::string &class_name)
 Set the name of the class in which the exception was thrown.
 
void SetExceptionStack (const std::vector< std::string > &nested_exceptions)
 Set the nested exceptions as strings.
 
std::vector< std::string > GetExceptionStack () const
 Retrieves the nested exception stack as string.
 
std::string Dump () const
 Return the exception's details.
 
std::string DumpWithNested () const
 Return all the exception's details including details of nested exceptions.
 
virtual const char * what () const noexcept override
 Return the exception message.
 

Detailed Description

Base class for the exceptions thrown by RAD and its users.

This class is similar to the CII Exception class. The main differences are:

Mapping to CiiSerializableException (see /elt/ciisrv/include/CiiSerializableException.hpp) used to propagate an exception via CII/MAL: std::string ciiType -> GetTypeName() std::string ciiMethodName -> m_attrs->function_name std::string ciiClassName -> m_attrs->class_name std::string ciiFileName -> m_attrs->file_name std::string ciiHostName -> GetHostName() std::string ciiStackTrace -> std::vector<std::string> ciiExceptionStack -> m_attrs->exception_stack std::string ciiMessage -> m_attrs->message std::string ciiDetails -> m_attrs->details int64_t ciiCreationDate -> GetCreationDate()

Member Typedef Documentation

◆ ClockT

typedef std::chrono::system_clock rad::Exception::ClockT

The clock to use for determining the exception creation time.

Possible values:

  • std::chrono::system_clock
  • std::chrono::steady_clock
  • std::chrono::high_resolution_clock
  • std::chrono::utc_clock (C++20)

Constructor & Destructor Documentation

◆ Exception() [1/2]

rad::Exception::Exception ( const std::string & message)
explicit

Constructor.

Parameters
messagea message describing the error

◆ Exception() [2/2]

rad::Exception::Exception ( const std::string & message,
const std::string & info )
explicit

◆ ~Exception()

virtual rad::Exception::~Exception ( )
virtualdefault

Destructor.

Member Function Documentation

◆ Dump()

std::string rad::Exception::Dump ( ) const

Return the exception's details.

Returns
the exception details.

◆ DumpWithNested()

std::string rad::Exception::DumpWithNested ( ) const

Return all the exception's details including details of nested exceptions.

Returns
all the exception details + nested exceptions.

◆ GetCreationDate()

int64_t rad::Exception::GetCreationDate ( ) const

Return the exception creation time as number of seconds since Unix Epoch.

Returns
exception creation time as seconds since Unix epoch

◆ GetDetails()

std::string rad::Exception::GetDetails ( ) const

Get the exception details.

Returns
exception details

◆ GetExceptionStack()

std::vector< std::string > rad::Exception::GetExceptionStack ( ) const

Retrieves the nested exception stack as string.

Returns
vector of strings each representing an exception.

◆ GetFileName()

const std::string & rad::Exception::GetFileName ( ) const

Return the name of the file in which the exception was thrown.

Returns
the name of the file in which the exception was thrown

◆ GetFullStackTraceAsString()

std::string rad::Exception::GetFullStackTraceAsString ( ) const

Return the full stack trace (including nested exceptions)

Returns
a string representing the full stack trace (including nested exceptions)

◆ GetFunctionName()

const std::string & rad::Exception::GetFunctionName ( ) const

Return the name of the function in which the exception was thrown.

Returns
the name of the function in which the exception was thrown

◆ GetHostName()

std::string rad::Exception::GetHostName ( ) const

Return the name of the host in which the exception was created.

Returns
the name of the host in which the exception was created

◆ GetLineNumber()

uint32_t rad::Exception::GetLineNumber ( ) const

Return the line number in which the exception was thrown.

Returns
the line number in which the exception was thrown

◆ GetOriginalStackTrace()

const boost::stacktrace::stacktrace & rad::Exception::GetOriginalStackTrace ( ) const

Return the stack trace captured in the most nested exception constructor.

Returns
the stack trace captured in the most nested exception constructor

◆ GetOriginalStackTraceAsString()

std::string rad::Exception::GetOriginalStackTraceAsString ( ) const

Same as GetOriginalStackTrace() but convert the trace to a string.

Returns
a string representing the most nested exception's stack trace

◆ GetProcessId()

int rad::Exception::GetProcessId ( ) const

Return the id of the process in which the exception was created.

Returns
the id of the process in which the exception was created

◆ GetStackTrace()

const boost::stacktrace::stacktrace & rad::Exception::GetStackTrace ( ) const

Return the stack trace captured in the exception constructor.

Returns
the stack trace captured in the exception constructor

◆ GetStackTraceAsString()

std::string rad::Exception::GetStackTraceAsString ( ) const

Same as GetStackTrace() but convert the trace to a string.

Returns
a string representing the stack trace

◆ GetThreadId()

std::thread::id rad::Exception::GetThreadId ( ) const

Return the id of the thread in which the exception was created.

Returns
the id of the thread in which the exception was created

◆ GetTimePoint()

std::chrono::time_point< Exception::ClockT > rad::Exception::GetTimePoint ( ) const

Return the exception creation time as a chrono timepoint.

Returns
the exception creation time

◆ GetTypeName()

std::string rad::Exception::GetTypeName ( ) const

Return the exception class name.

Returns
the exception class name

◆ SetClassName()

void rad::Exception::SetClassName ( const std::string & class_name)

Set the name of the class in which the exception was thrown.

Parameters
class_namethe name of the class in which the exception was thrown.

◆ SetDetails()

void rad::Exception::SetDetails ( const std::string & details)

Set the exception details.

Parameters
detailsnew exception details

◆ SetExceptionStack()

void rad::Exception::SetExceptionStack ( const std::vector< std::string > & nested_exceptions)

Set the nested exceptions as strings.

Parameters
nested_exceptionsNested exceptions as string.

◆ SetFileName()

void rad::Exception::SetFileName ( const std::string & file_name)

Set the name of the file in which the exception was thrown.

Parameters
fileNamethe name of the file in which the exception was thrown

◆ SetFunctionName()

void rad::Exception::SetFunctionName ( const std::string & function_name)

Set the name of the function in which the exception was thrown.

Parameters
functionNamethe name of the function in which the exception was thrown

◆ SetLineNumber()

void rad::Exception::SetLineNumber ( uint32_t line_number)

Set the line number in which the exception was thrown.

Parameters
lineNumberthe line number in which the exception was thrown

◆ what()

const char * rad::Exception::what ( ) const
overridevirtualnoexcept

Return the exception message.


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