5#include <source_location>
18 std::source_location m_location;
19 std::stacktrace m_trace;
29 std::runtime_error(message), m_location(
location), m_trace(std::move(
trace)) { }
44 const std::source_location&
location() const noexcept {
52 const std::stacktrace&
trace() const noexcept {
62 std::string m_argument;
70 Exception(std::format(
"Invalid argument provided: {}.",
argument), std::source_location::current(), std::stacktrace::current()), m_argument(
argument) { }
78 Exception(std::format(
"Invalid argument provided: {}. {}",
argument, message), std::source_location::current(), std::stacktrace::current()), m_argument(
argument) { }
86 template <
typename ...TArgs>
88 Exception(std::format(
"Invalid argument provided: {}. {}",
argument, std::format(format, std::forward<TArgs>(args)...)), std::source_location::current(), std::stacktrace::current()), m_argument(
argument) { }
112 std::string m_argument;
120 Exception(std::format(
"Argument was out of range: {}.",
argument), std::source_location::current(), std::stacktrace::current()), m_argument(
argument) { }
128 Exception(std::format(
"Argument was out of range: {}. {}",
argument, message), std::source_location::current(), std::stacktrace::current()), m_argument(
argument) { }
148 template <
typename ...TArgs>
150 Exception(std::format(
"Argument was out of range: {}. {}",
argument, std::format(format, std::forward<TArgs>(args)...)), std::source_location::current(), std::stacktrace::current()), m_argument(
argument) { }
161 template <
typename T,
typename ...TArgs>
163 Exception(std::format(
"Argument was out of range: {} (valid range is [{}, {}) but actual value was {}). {}",
argument, validRange.first, validRange.second, value, std::format(format, std::forward<TArgs>(args)...)), std::source_location::current(), std::stacktrace::current()), m_argument(
argument) { }
187 std::string m_argument;
195 Exception(std::format(
"Argument was not initialized: {}.",
argument), std::source_location::current(), std::stacktrace::current()), m_argument(
argument) { }
203 Exception(std::format(
"Argument was not initialized: {}. {}",
argument, message), std::source_location::current(), std::stacktrace::current()), m_argument(
argument) { }
211 template <
typename ...TArgs>
213 Exception(std::format(
"Argument was not initialized: {}. {}",
argument, std::format(format, std::forward<TArgs>(args)...)), std::source_location::current(), std::stacktrace::current()), m_argument(
argument) { }
241 Exception(
"The operation could not be executed.", std::source_location::current(), std::stacktrace::current()) { }
248 Exception(std::format(
"The operation could not be executed: {}", message), std::source_location::current(), std::stacktrace::current()) { }
255 template <
typename ...TArgs>
257 Exception(std::format(
"The operation could not be executed: {}", std::format(format, std::forward<TArgs>(args)...)), std::source_location::current(), std::stacktrace::current()) { }
An exception that is thrown, if a provided non-optional argument was not initialized.
Definition exceptions.hpp:185
const std::string & argument() const noexcept
Gets the name of the argument that was not initialized.
Definition exceptions.hpp:227
ArgumentNotInitializedException(ArgumentNotInitializedException &&) noexcept=default
ArgumentNotInitializedException(std::string_view argument, std::format_string< TArgs... > format, TArgs &&... args)
Initializes a new exception.
Definition exceptions.hpp:212
ArgumentNotInitializedException(const ArgumentNotInitializedException &)=default
ArgumentNotInitializedException(std::string_view argument)
Initializes a new exception.
Definition exceptions.hpp:194
ArgumentNotInitializedException(std::string_view argument, std::string_view message)
Initializes a new exception.
Definition exceptions.hpp:202
An exception that is thrown, if a provided argument is not within the expected range.
Definition exceptions.hpp:110
ArgumentOutOfRangeException(const ArgumentOutOfRangeException &)=default
ArgumentOutOfRangeException(std::string_view argument, std::pair< T, T > validRange, T value, std::format_string< TArgs... > format, TArgs &&... args)
Initializes a new exception.
Definition exceptions.hpp:162
ArgumentOutOfRangeException(ArgumentOutOfRangeException &&) noexcept=default
ArgumentOutOfRangeException(std::string_view argument, std::string_view message)
Initializes a new exception.
Definition exceptions.hpp:127
ArgumentOutOfRangeException(std::string_view argument, std::format_string< TArgs... > format, TArgs &&... args)
Initializes a new exception.
Definition exceptions.hpp:149
const std::string & argument() const noexcept
Gets the name of the argument that was out of range.
Definition exceptions.hpp:177
ArgumentOutOfRangeException(std::string_view argument)
Initializes a new exception.
Definition exceptions.hpp:119
The base class for exceptions thrown by the SDK.
Definition exceptions.hpp:16
Exception(const std::string &message, const std::source_location &location, std::stacktrace trace)
Initializes the exception.
Definition exceptions.hpp:28
const std::stacktrace & trace() const noexcept
Gets the stack trace leading to the exception.
Definition exceptions.hpp:52
Exception(Exception &&) noexcept=default
Exception(const Exception &)=default
const std::source_location & location() const noexcept
Gets the source location that identifies where the exception has been thrown.
Definition exceptions.hpp:44
An exception that is thrown, if a provided argument is not valid.
Definition exceptions.hpp:60
InvalidArgumentException(std::string_view argument, std::string_view message)
Initializes a new exception.
Definition exceptions.hpp:77
const std::string & argument() const noexcept
Gets the name of the argument that was invalid.
Definition exceptions.hpp:102
InvalidArgumentException(InvalidArgumentException &&) noexcept=default
InvalidArgumentException(const InvalidArgumentException &)=default
InvalidArgumentException(std::string_view argument, std::format_string< TArgs... > format, TArgs &&... args)
Initializes a new exception.
Definition exceptions.hpp:87
InvalidArgumentException(std::string_view argument)
Initializes a new exception.
Definition exceptions.hpp:69
An exception that is thrown, if a requested operation could not be executed.
Definition exceptions.hpp:235
RuntimeException()
Initializes a new exception.
Definition exceptions.hpp:240
RuntimeException(std::string_view message)
Initializes a new exception.
Definition exceptions.hpp:247
RuntimeException(const RuntimeException &)=default
RuntimeException(std::format_string< TArgs... > format, TArgs &&... args)
Initializes a new exception.
Definition exceptions.hpp:256
RuntimeException(RuntimeException &&) noexcept=default