5#ifndef INCLUDE_FIFECHAN_EXCEPTION_HPP_
6#define INCLUDE_FIFECHAN_EXCEPTION_HPP_
8#include <source_location>
13#include "fifechan/platform.hpp"
44 explicit Exception(std::string message, std::source_location location = std::source_location::current()) :
45 std::runtime_error(message),
46 mMessage(std::move(message)),
47 mFunction(location.function_name()),
48 mFilename(location.file_name()),
49 mLine(location.line())
58 char const *
what() const noexcept
override
60 return mMessage.c_str();
107 std::string mMessage =
"Message?";
112 std::string mFunction =
"Function?";
117 std::string mFilename =
"Filename?";
122 unsigned int mLine = 0;
125 inline void throwException(
126 std::string
const & message, std::source_location location = std::source_location::current())
128 throw Exception(message, location);
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.