tk::Exception class

Basic exception class for producing file:func:line info + call trace.

The basic functionality provided by the Exception class is to facilitate printing out a message, together with the location of the exception (file, line, funcion name), as well as a call trace if available, when an exception is thrown.

Constructors, destructors, conversion operators

Exception(std::string&& message, std::string&& file = "", std::string&& function = "", unsigned int line = 0) explicit noexcept
Constructor.
~Exception() noexcept override virtual
Destructor.
Exception(Exception&&) defaulted
Force move constructor for throws.

Public functions

auto what() const noexcept override -> const char* virtual
auto handleException() -> ErrCode virtual noexcept
Handle Exception.
auto func() const -> const std::string& noexcept

Function documentation

tk::Exception::Exception(std::string&& message, std::string&& file = "", std::string&& function = "", unsigned int line = 0) explicit noexcept

Constructor.

Parameters
message in String (moved from) with an error message
file in String (moved from) with the file name in which the exception ocurred
function in String (moved from) containing the name of the function in which the exception ocurred
line in Source code line number at which the exception ocurred

While throwing exceptions is possible calling this constructor, the easiest and recommend way is to use the Assert, ErrChk, and Throw macros. Exception safety: no-throw guarantee: this member function never throws exceptions.

tk::Exception::~Exception() noexcept override virtual

Destructor.

Exception safety: no-throw guarantee: this member function never throws exceptions.

const char* tk::Exception::what() const noexcept override virtual

Returns C-style string to exception message

Redefine std::exception's what()

ErrCode tk::Exception::handleException() virtual noexcept

Handle Exception.

Returns Error code, as defined in stdlib.h, i.e., cstdlib

Exception safety: no-throw guarantee: this member function never throws exceptions.

const std::string& tk::Exception::func() const noexcept

Returns Reference to function name in which the exception occurred

Accessor to function name