3#if __clang__ && __clang_major__ <= 14
4#include <experimental/source_location>
7#include <source_location>
10#include <spdlog/fmt/fmt.h>
20 template <
typename... Args>
23 mReason = fmt::vformat(format, fmt::make_format_args(std::forward<Args>(args)...));
26 inline virtual const char*
what() const noexcept
override {
return mReason.c_str(); }
33 [[ noreturn ]]
static void Throw(std::string_view reason,
const source_location location = source_location::current());
40 template <
typename... Args>
41 [[ noreturn ]]
inline static void Throw(
const source_location location,
const char*
const format, Args&&... args)
43 std::string reason = fmt::vformat(format, fmt::make_format_args(std::forward<Args>(args)...));
44 Throw(reason, location);
61 inline void Assert(
bool condition, std::string_view message,
const source_location location = source_location::current())
72#define FORAY_ASSERTFMT(val, fmt, ...) \
75 const source_location __foray_location = source_location::current(); \
76 foray::Exception::Throw(__foray_location, fmt, __VA_ARGS__); \
81#define FORAY_THROWFMT(fmt, ...) \
83 const source_location __foray_location = source_location::current(); \
84 foray::Exception::Throw(__foray_location, fmt, __VA_ARGS__); \
An extension of std::exception providing support for formatted error messages. Exceptions should alwa...
Definition foray_exception.hpp:16
static void Throw(std::string_view reason, const source_location location=source_location::current())
Throws an exception.
static void Throw(const source_location location, const char *const format, Args &&... args)
Throws an exception.
Definition foray_exception.hpp:41
Exception(const char *const format, Args &&... args)
Definition foray_exception.hpp:21
Exception(std::string_view reason)
Definition foray_exception.hpp:19
Exception()
Definition foray_exception.hpp:18
std::string mReason
Definition foray_exception.hpp:48
virtual const char * what() const noexcept override
Definition foray_exception.hpp:26
std::source_location source_location
Definition foray_exception.hpp:8
Definition foray_api.hpp:19
void Assert(bool condition, const source_location location=source_location::current())
Asserts condition. Throws a generic error message if conditition is false.
Definition foray_exception.hpp:52