5#ifndef INCLUDE_FIFECHAN_EXCEPTION_HPP_
6#define INCLUDE_FIFECHAN_EXCEPTION_HPP_
9#include <source_location>
43 explicit Exception(std::string message, std::source_location location = std::source_location::current()) :
44 std::runtime_error(message),
45 mMessage(std::move(message)),
46 mFunction(location.function_name()),
47 mFilename(location.file_name()),
48 mLine(location.line())
57 char const *
what() const noexcept
override
59 return mMessage.c_str();
106 std::string mMessage =
"Message?";
111 std::string mFunction =
"Function?";
116 std::string mFilename =
"Filename?";
121 unsigned int mLine = 0;
131 std::string
const & message, std::source_location location = std::source_location::current())
An exception class containing a message, a file, and a line number where the exception occurred.
char const * what() const noexcept override
Returns a pointer to a null-terminated string with a description of the exception.
std::string const & getMessage() const
Gets the message of the exception.
std::string const & getFilename() const
Gets the filename where the exception occurred.
unsigned int getLine() const
Gets the line number where the exception occurred.
std::string const & getFunction() const
Gets the function name where the exception occurred.
Exception(std::string message, std::source_location location=std::source_location::current())
Constructor that takes a message and source location.
Used replacement tokens by configure_file():
void throwException(std::string const &message, std::source_location location=std::source_location::current())
Throw an Exception capturing the current source location.