8#include <SDL3/SDL_error.h>
9#include "SDL3pp_strings.h"
68 return SDL_SetError(
"%s",
static_cast<const char*
>(message));
105template<
class... ARGS>
106inline bool SetError(std::string_view fmt, ARGS... args)
109 std::vformat(fmt, std::make_format_args(std::forward<ARGS>(args)...)));
160inline const char*
GetError() {
return SDL_GetError(); }
168 std::string m_message;
175 : m_message(SDL_GetError())
183 : m_message(std::move(message))
190 constexpr const char*
what() const noexcept {
return m_message.c_str(); }
195 constexpr const std::string&
str() const noexcept {
return m_message; }
208 if (!result)
throw Error();
222 if (!result)
throw Error();
239 if (result == invalidValue)
throw Error();
269#define SDL_Unsupported() SDL_SetError("That operation is not supported")
293#define SDL_InvalidParamError(param) \
294 SDL_SetError("Parameter '%s' is invalid", (param))
An exception that returns GetError()
Definition SDL3pp_error.h:167
constexpr const char * what() const noexcept
Returns the explanatory string.
Definition SDL3pp_error.h:190
Error()
Default ctor.
Definition SDL3pp_error.h:174
Error(std::string message)
Constructs from string.
Definition SDL3pp_error.h:182
constexpr const std::string & str() const noexcept
Returns the explanatory string.
Definition SDL3pp_error.h:195
Helpers to use C++ strings parameters.
Definition SDL3pp_strings.h:43
bool SetErrorUnformatted(StringParam message)
Set the SDL error message for the current thread.
Definition SDL3pp_error.h:66
bool OutOfMemory()
Set an error indicating that memory allocation failed.
Definition SDL3pp_error.h:123
const char * GetError()
Retrieve a message about the last error that occurred on the current thread.
Definition SDL3pp_error.h:160
bool ClearError()
Clear any previous error message for this thread.
Definition SDL3pp_error.h:255
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition SDL3pp_error.h:206
bool SetError(std::string_view fmt, ARGS... args)
Set the SDL error message for the current thread.
Definition SDL3pp_error.h:106
the main namespace where all SDL3pp public functions and types live
Definition SDL3pp_assert.h:7