libSDL2pp
C++ bindings/wrapper for SDL2
|
Exception object representing SDL2 error More...
#include <SDL2pp/Exception.hh>
Public Member Functions | |
Exception (const char *function) | |
Construct exception, storing result of SDL_GetError() | |
Exception (const Exception &)=default | |
Copy constructor. | |
virtual | ~Exception () noexcept |
Destructor. | |
std::string | GetSDLFunction () const |
Get name of SDL function which caused an error. | |
std::string | GetSDLError () const |
Get SDL2 error text. | |
Exception object representing SDL2 error
Internally, libSDL2pp checks return value of each SDL2 function it calls which may fail. If the function fails, SDL2pp::Exception is thrown, and SDL2 error which explains cause of function failure is stored in the exception and may be extracted later.
what() usually contains a name of SDL2 function which failed, e.g. "SDL_Init() failed"
Note: this Exception object is used to report errors from SDL2 satellite libraries (SDL_image, SDL_mixer, SDL_ttf) as well. Though they use their own error handling functions (IMG_GetError, Mix_GetError, TTF_GetError), those are (currently) just macros pointing to SDL_GetError. We currently rely on that. If that changes, we'll need a hierarchy of specific exceptions.
Usage example:
|
explicit |
Construct exception, storing result of SDL_GetError()
[in] | function | Name of SDL function which generated an error |
|
default |
Copy constructor.
|
virtualnoexcept |
Destructor.
std::string SDL2pp::Exception::GetSDLError | ( | ) | const |
Get SDL2 error text.
std::string SDL2pp::Exception::GetSDLFunction | ( | ) | const |
Get name of SDL function which caused an error.