mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
mx::err::mxException Class Reference

The mxlib exception class.

Provides a rich error report via the standard what().

Definition at line 44 of file mxException.hpp.

#include <mxException.hpp>

+ Inheritance diagram for mx::err::mxException:

Public Member Functions

 mxException () noexcept
 Default constructor. More...
 
 mxException (const mxException &e) noexcept
 Copy constructor. More...
 
 mxException (const std::string &esrc, const int &ec, const std::string &emnem, const std::string &efile, const int &line, const std::string &expl)
 Construct and fill in each of the values, except errno. More...
 
 mxException (const std::string &esrc, const int &ec, const std::string &emnem, const int &en, const std::string &efile, const int &line, const std::string &expl)
 Construct and fill in each of the values, including errno. More...
 
mxExceptionoperator= (const mxException &e) noexcept
 Assignment operator. More...
 
virtual ~mxException () throw ()
 Destructor. More...
 
virtual void build_what ()
 Build the what string. More...
 
virtual const char * what () const noexcept
 Return the details of the exception as a single string. More...
 

Protected Attributes

char m_whatstr [4096]
 Contains the what() string. More...
 
std::string m_source {""}
 The source of the exception, such as stdlib or cfitisio or the function name. More...
 
int m_code {0}
 The mxlib error code. More...
 
std::string m_codeName {""}
 The name of the error code. More...
 
int m_errno {0}
 The errno error code (only used if non-zero) More...
 
std::string m_file {""}
 The source file where the exception originated. More...
 
int m_line {0}
 The line number of the file where the exception originated. More...
 
std::string m_explanation {""}
 The long explanation of the error. More...
 

Constructor & Destructor Documentation

◆ mxException() [1/4]

mx::err::mxException::mxException ( )
inlinenoexcept

Default constructor.

Definition at line 75 of file mxException.hpp.

References build_what().

◆ mxException() [2/4]

mx::err::mxException::mxException ( const mxException e)
inlinenoexcept

Copy constructor.

Definition at line 81 of file mxException.hpp.

References build_what().

◆ mxException() [3/4]

mx::err::mxException::mxException ( const std::string &  esrc,
const int &  ec,
const std::string &  emnem,
const std::string &  efile,
const int &  line,
const std::string &  expl 
)
inline

Construct and fill in each of the values, except errno.

Parameters
[in]esrcthe source of the exception, typically the class and function
[in]ecthe error code
[in]emnemthe name of the error code
[in]efilethe source file in which the exception occurred, normally __FILE__
[in]linethe line number where the exception was thrown
[in]explthe explanation for why the exception was thrown

Definition at line 87 of file mxException.hpp.

References build_what().

◆ mxException() [4/4]

mx::err::mxException::mxException ( const std::string &  esrc,
const int &  ec,
const std::string &  emnem,
const int &  en,
const std::string &  efile,
const int &  line,
const std::string &  expl 
)
inline

Construct and fill in each of the values, including errno.

Parameters
[in]esrcthe source of the exception, typically the class and function
[in]ecthe error code
[in]emnemthe name of the error code
[in]enthe value of errno
[in]efilethe source file in which the exception occurred, normally __FILE__
[in]linethe line number where the exception was thrown
[in]explthe explanation for why the exception was thrown

Definition at line 99 of file mxException.hpp.

References build_what().

◆ ~mxException()

virtual mx::err::mxException::~mxException ( )
throw (
)
inlinevirtual

Destructor.

Definition at line 128 of file mxException.hpp.

Member Function Documentation

◆ build_what()

virtual void mx::err::mxException::build_what ( )
inlinevirtual

Build the what string.

Must be called after updating any values, since the what() method is const const.

Definition at line 135 of file mxException.hpp.

References mx::errno_CodeToName(), m_code, m_codeName, m_errno, m_explanation, m_file, m_line, m_source, and m_whatstr.

Referenced by mxException(), and operator=().

◆ operator=()

mxException& mx::err::mxException::operator= ( const mxException e)
inlinenoexcept

Assignment operator.

Definition at line 112 of file mxException.hpp.

References build_what(), m_code, m_codeName, m_errno, m_explanation, m_file, m_line, and m_source.

◆ what()

virtual const char* mx::err::mxException::what ( ) const
inlinevirtualnoexcept

Return the details of the exception as a single string.

Definition at line 162 of file mxException.hpp.

References m_whatstr.

Member Data Documentation

◆ m_code

int mx::err::mxException::m_code {0}
protected

The mxlib error code.

Definition at line 55 of file mxException.hpp.

Referenced by build_what(), and operator=().

◆ m_codeName

std::string mx::err::mxException::m_codeName {""}
protected

The name of the error code.

Definition at line 58 of file mxException.hpp.

Referenced by build_what(), and operator=().

◆ m_errno

int mx::err::mxException::m_errno {0}
protected

The errno error code (only used if non-zero)

Definition at line 61 of file mxException.hpp.

Referenced by build_what(), and operator=().

◆ m_explanation

std::string mx::err::mxException::m_explanation {""}
protected

The long explanation of the error.

Definition at line 70 of file mxException.hpp.

Referenced by build_what(), and operator=().

◆ m_file

std::string mx::err::mxException::m_file {""}
protected

The source file where the exception originated.

Definition at line 64 of file mxException.hpp.

Referenced by build_what(), and operator=().

◆ m_line

int mx::err::mxException::m_line {0}
protected

The line number of the file where the exception originated.

Definition at line 67 of file mxException.hpp.

Referenced by build_what(), and operator=().

◆ m_source

std::string mx::err::mxException::m_source {""}
protected

The source of the exception, such as stdlib or cfitisio or the function name.

Definition at line 52 of file mxException.hpp.

Referenced by build_what(), and operator=().

◆ m_whatstr

char mx::err::mxException::m_whatstr[4096]
protected

Contains the what() string.

Definition at line 49 of file mxException.hpp.

Referenced by build_what(), and what().


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