3#include <StormByte/visibility.h>
45 template <
typename... Args>
46 Exception(std::format_string<Args...> fmt, Args&&... args) {
47 if constexpr (
sizeof...(Args) == 0) {
49 m_what = copy_str(fmt);
52 std::string formatted_message = std::format(fmt, std::forward<Args>(args)...);
53 m_what = copy_str(formatted_message.c_str());
57 template <
typename... Args>
58 Exception(
const std::string& component, std::format_string<Args...> fmt, Args&&... args) {
59 std::string formatted_message = std::format(fmt, std::forward<Args>(args)...);
60 std::string full_message =
"StormByte::" +component +
": " + formatted_message;
61 m_what = copy_str(full_message.c_str());
99 virtual const
char* what() const noexcept;
109 const
char* copy_str(const
char* str) noexcept;
114 void free_str() noexcept;
123 using Exception::Exception;
132 using Exception::Exception;
Exception thrown during deserialization errors.
Definition exception.hxx:121
Base class for exceptions in the StormByte library.
Definition exception.hxx:23
Exception(const std::string &message)
Constructor.
Exception(std::string &&message)
Constructor.
Exception(Exception &&e) noexcept
Move constructor.
Exception(const Exception &e)
Copy constructor.
Exception(std::format_string< Args... > fmt, Args &&... args)
Constructor forwards the message to the std::format function.
Definition exception.hxx:46
virtual ~Exception() noexcept
Destructor.
Exception thrown when an out-of-bounds access is attempted.
Definition exception.hxx:130
Main namespace for the StormByte library.