Tinker9 70bd052 (Thu Nov 9 12:11:35 2023 -0800)
Loading...
Searching...
No Matches
Classes | Macros | Functions
Errors and Exceptions

Classes

class  tinker::FatalError
 Errors and exceptions that we do not intend to fix or handle. More...
 

Macros

#define TINKER_THROW(msg)
 Throws a fatal error message as a tinker::FatalError exception. More...
 
#define TINKER_ALWAYS_CHECK_RT_1_(call)
 
#define TINKER_ALWAYS_CHECK_RT_(...)   TINKER_GET_2ND_ARG(__VA_ARGS__, TINKER_ALWAYS_CHECK_RT_1_)
 
#define TINKER_ALWAYS_CHECK_RT   0
 Defined to true in the source code to enable check_rt for the release build. More...
 
#define check_rt(call, ...)   call
 It normally does not do extra work other than the function call it captures, unless if either TINKER_DEBUG or TINKER_ALWAYS_CHECK_RT is true. This macro will then check the error code returned by the function call. More...
 
#define always_check_rt(...)   TINKER_ALWAYS_CHECK_RT_(__VA_ARGS__)(__VA_ARGS__)
 Always checks the returned error code. More...
 

Functions

template<class T >
std::string tinker::translateErrorCode (T errcode)
 Translates the error code to text. More...
 
void tinker::printError ()
 Writes the current coordinates to a disk file prior to aborting on a serious error. More...
 
void tinker::printBacktrace (std::FILE *out=stderr)
 Prints the call stack to a FILE pointer. More...
 

Detailed Description


Class Documentation

◆ tinker::FatalError

class tinker::FatalError

Errors and exceptions that we do not intend to fix or handle.

Public Member Functions

 FatalError (const char *msg)
 
 FatalError (const std::string &msg)
 
 FatalError (const FatalError &e)
 
const char * what () const noexcept override
 

Constructor & Destructor Documentation

◆ FatalError() [1/3]

tinker::FatalError::FatalError ( const char *  msg)
inline

◆ FatalError() [2/3]

tinker::FatalError::FatalError ( const std::string &  msg)
inline

◆ FatalError() [3/3]

tinker::FatalError::FatalError ( const FatalError e)
inline

Member Function Documentation

◆ what()

const char * tinker::FatalError::what ( ) const
inlineoverridenoexcept

Macro Definition Documentation

◆ always_check_rt

#define always_check_rt (   ...)    TINKER_ALWAYS_CHECK_RT_(__VA_ARGS__)(__VA_ARGS__)

Always checks the returned error code.

See also
check_rt

◆ check_rt

#define check_rt (   call,
  ... 
)    call

It normally does not do extra work other than the function call it captures, unless if either TINKER_DEBUG or TINKER_ALWAYS_CHECK_RT is true. This macro will then check the error code returned by the function call.

See also
TINKER_DEBUG
TINKER_ALWAYS_CHECK_RT

◆ TINKER_ALWAYS_CHECK_RT

#define TINKER_ALWAYS_CHECK_RT   0

Defined to true in the source code to enable check_rt for the release build.

See also
check_rt

◆ TINKER_ALWAYS_CHECK_RT_

#define TINKER_ALWAYS_CHECK_RT_ (   ...)    TINKER_GET_2ND_ARG(__VA_ARGS__, TINKER_ALWAYS_CHECK_RT_1_)

◆ TINKER_ALWAYS_CHECK_RT_1_

#define TINKER_ALWAYS_CHECK_RT_1_ (   call)
Value:
do { \
auto res_ = call; \
if (res_ != 0) { \
printBacktrace(); \
std::string m_; \
std::string msg_ = translateErrorCode(res_); \
if (msg_ != "") \
m_ = format("Errno %d (%s) at %s:%d", res_, msg_, __FILE__, __LINE__); \
else \
m_ = format("Errno %d at %s:%d", res_, __FILE__, __LINE__); \
throw FatalError(m_); \
} \
} while (0)

◆ TINKER_THROW

#define TINKER_THROW (   msg)
Value:
do { \
printBacktrace(); \
std::string ms_ = msg; \
std::string m_ = format("%s at %s:%d", ms_, __FILE__, __LINE__); \
throw FatalError(m_); \
} while (0)

Throws a fatal error message as a tinker::FatalError exception.

Function Documentation

◆ printBacktrace()

void tinker::printBacktrace ( std::FILE *  out = stderr)

Prints the call stack to a FILE pointer.

◆ printError()

void tinker::printError ( )

Writes the current coordinates to a disk file prior to aborting on a serious error.

◆ translateErrorCode()

template<class T >
std::string tinker::translateErrorCode ( errcode)

Translates the error code to text.