mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Loading...
Searching...
No Matches
mx::exception< verboseT > Class Template Reference

template<class verboseT = verbose::d>
class mx::exception< verboseT >

Augments an exception with the source file and line.

Template Parameters
baseexceptis the base class exception which takes a string as constructor argument

Definition at line 41 of file exception.hpp.

#include <error/exception.hpp>

Inherits std::exception.

Public Member Functions

 exception (const std::source_location loc=std::source_location::current())
 Constructor with location only.
 
 exception (const std::string &msg, const std::source_location loc=std::source_location::current())
 Constructor with message.
 
 exception (error_t code, const std::string &msg, const std::source_location loc=std::source_location::current())
 Constructor with message and cod.
 
 exception (error_t code, const std::source_location loc=std::source_location::current())
 Constructor with code.
 
virtual const char * what () const noexcept
 Get the what string.
 
const std::string & message () const
 Get the message.
 
const std::string file_name () const
 Get the source file.
 
int line () const
 Get the source line.
 
error_t code () const
 Get the error code.
 

Protected Attributes

std::string m_what
 The full what message (message + file information).
 
error_t m_code { error_t::exception }
 The error_t code.
 
std::string m_message
 The explanatory message.
 

Constructor & Destructor Documentation

◆ exception() [1/4]

template<class verboseT = verbose::d>
mx::exception< verboseT >::exception ( const std::source_location  loc = std::source_location::current())
inlineexplicit

Constructor with location only.

Parameters
[in]loc[opt] the location where this was thrown

Definition at line 56 of file exception.hpp.

References mx::exception< verboseT >::m_code, and mx::exception< verboseT >::m_what.

◆ exception() [2/4]

template<class verboseT = verbose::d>
mx::exception< verboseT >::exception ( const std::string &  msg,
const std::source_location  loc = std::source_location::current() 
)
inlineexplicit

Constructor with message.

Parameters
[in]msgthe error description message)
[in]loc[opt] the location where this was thrown

Definition at line 66 of file exception.hpp.

References mx::exception< verboseT >::m_code, mx::exception< verboseT >::m_message, and mx::exception< verboseT >::m_what.

◆ exception() [3/4]

template<class verboseT = verbose::d>
mx::exception< verboseT >::exception ( error_t  code,
const std::string &  msg,
const std::source_location  loc = std::source_location::current() 
)
inline

Constructor with message and cod.

Parameters
[in]codea descriptive error code
[in]msgthe error description (what message)
[in]loc[opt] the location where this was thrown

Definition at line 77 of file exception.hpp.

References mx::exception< verboseT >::m_code, mx::exception< verboseT >::m_message, and mx::exception< verboseT >::m_what.

◆ exception() [4/4]

template<class verboseT = verbose::d>
mx::exception< verboseT >::exception ( error_t  code,
const std::source_location  loc = std::source_location::current() 
)
inline

Constructor with code.

The message is filled in using errorMessage.

The what() message becomes "code_message (code) [file line]".

Parameters
[in]codea descriptive error code
[in]loc[opt] the location where this was thrown

Definition at line 91 of file exception.hpp.

References mx::exception< verboseT >::m_code, and mx::exception< verboseT >::m_what.

Member Function Documentation

◆ code()

template<class verboseT = verbose::d>
error_t mx::exception< verboseT >::code ( ) const
inline

Get the error code.

Returns
the value of m_code

Definition at line 139 of file exception.hpp.

References mx::exception< verboseT >::m_code.

Referenced by mx::ioutils::dir_exists_is(), and mx::ioutils::exists().

◆ file_name()

template<class verboseT = verbose::d>
const std::string mx::exception< verboseT >::file_name ( ) const
inline

Get the source file.

Returns
the value of m_location.file_name()

Definition at line 121 of file exception.hpp.

◆ line()

template<class verboseT = verbose::d>
int mx::exception< verboseT >::line ( ) const
inline

Get the source line.

Returns
the value of m_location.line()

Definition at line 130 of file exception.hpp.

◆ message()

template<class verboseT = verbose::d>
const std::string & mx::exception< verboseT >::message ( ) const
inline

Get the message.

Returns
the value of m_message

Definition at line 112 of file exception.hpp.

References mx::exception< verboseT >::m_message.

◆ what()

template<class verboseT = verbose::d>
virtual const char * mx::exception< verboseT >::what ( ) const
inlinevirtualnoexcept

Get the what string.

Returns
the value of m_what.c_str()

Definition at line 103 of file exception.hpp.

References mx::exception< verboseT >::m_what.

Member Data Documentation

◆ m_code

◆ m_message

template<class verboseT = verbose::d>
std::string mx::exception< verboseT >::m_message
protected

◆ m_what

template<class verboseT = verbose::d>
std::string mx::exception< verboseT >::m_what
protected

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