SDL 2.0
|
Go to the source code of this file.
Functions | |
int | SDL_SetError (SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(1) |
const char * | SDL_GetError (void) |
char * | SDL_GetErrorMsg (char *errstr, int maxlen) |
void | SDL_ClearError (void) |
Internal error functions | |
Private error reporting function - used internally. | |
#define | SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) |
#define | SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) |
#define | SDL_InvalidParamError(param) SDL_SetError("Parameter '%s' is invalid", (param)) |
enum | SDL_errorcode { SDL_ENOMEM , SDL_EFREAD , SDL_EFWRITE , SDL_EFSEEK , SDL_UNSUPPORTED , SDL_LASTERROR } |
int | SDL_Error (SDL_errorcode code) |
Simple error message routines for SDL.
Definition in file SDL_error.h.
#define SDL_InvalidParamError | ( | param | ) | SDL_SetError("Parameter '%s' is invalid", (param)) |
Definition at line 141 of file SDL_error.h.
#define SDL_OutOfMemory | ( | ) | SDL_Error(SDL_ENOMEM) |
Definition at line 139 of file SDL_error.h.
#define SDL_Unsupported | ( | ) | SDL_Error(SDL_UNSUPPORTED) |
Definition at line 140 of file SDL_error.h.
enum SDL_errorcode |
Enumerator | |
---|---|
SDL_ENOMEM | |
SDL_EFREAD | |
SDL_EFWRITE | |
SDL_EFSEEK | |
SDL_UNSUPPORTED | |
SDL_LASTERROR |
Definition at line 142 of file SDL_error.h.
void SDL_ClearError | ( | void | ) |
Clear any previous error message for this thread.
int SDL_Error | ( | SDL_errorcode | code | ) |
const char * SDL_GetError | ( | void | ) |
Retrieve a message about the last error that occurred on the current thread.
It is possible for multiple errors to occur before calling SDL_GetError(). Only the last error is returned.
The message is only applicable when an SDL function has signaled an error. You must check the return values of SDL function calls to determine when to appropriately call SDL_GetError(). You should not use the results of SDL_GetError() to decide if an error has occurred! Sometimes SDL will set an error string even when reporting success.
SDL will not clear the error string for successful API calls. You must check return values for failure cases before you can assume the error string applies.
Error strings are set per-thread, so an error set in a different thread will not interfere with the current thread's operation.
The returned string is internally allocated and must not be freed by the application.
char * SDL_GetErrorMsg | ( | char * | errstr, |
int | maxlen | ||
) |
Get the last error message that was set for the current thread.
This allows the caller to copy the error string into a provided buffer, but otherwise operates exactly the same as SDL_GetError().
errstr | A buffer to fill with the last error message that was set for the current thread |
maxlen | The size of the buffer pointed to by the errstr parameter |
errstr
parameter.int SDL_SetError | ( | SDL_PRINTF_FORMAT_STRING const char * | fmt, |
... | |||
) |
Set the SDL error message for the current thread.
Calling this function will replace any previous error message that was set.
This function always returns -1, since SDL frequently uses -1 to signify an failing result, leading to this idiom:
fmt | a printf()-style message format string |
... | additional parameters matching % tokens in the fmt string, if any |