Wiki Page Content

Differences between revisions 10 and 11
Revision 10 as of 2012-08-06 19:28:57
Size: 1165
Editor: JonasThiem
Comment: hm, isn't that more accurate? does really EVERY sdl function support error handling? would every function even need to?
Revision 11 as of 2013-04-19 16:25:03
Size: 1395
Comment: Recommending checking return values before calling SDL_GetError().
Deletions are marked like this. Additions are marked like this.
Line 15: Line 15:
Returns a message with information about the specific error that occurred, or an empty string if there hasn't been an error since the last call to [[SDL_ClearError]](). Returns a message with information about the specific error that occurred, or an empty string if there hasn't been an error since the last call to [[SDL_ClearError]]().  Without calling [[SDL_ClearError]](), 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]]().

SDL_GetError

Use this function to retrieve a message about the last error that occurred.

Syntax

const char* SDL_GetError(void)

Return Value

Returns a message with information about the specific error that occurred, or an empty string if there hasn't been an error since the last call to SDL_ClearError(). Without calling SDL_ClearError(), 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().

This string is statically allocated and must not be freed by the application.

Code Examples

if (SDL_Init( SDL_INIT_EVERYTHING ) < 0) {
    // Unrecoverable error, exit here.
    printf("SDL_Init failed: %s\n", SDL_GetError());
}

Note: Although this example uses SDL_Init(), SDL_GetError() provides an error message for any failed SDL operation which supports error reporting, see the wiki page for each particular SDL function.

Remarks

It is possible for multiple errors to occur before calling SDL_GetError(). Only the last error is returned.


CategoryAPI, CategoryError

None: SDL_GetError (last edited 2016-05-11 20:27:55 by PhilippWiesemann)

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit