Wiki Page Content

Differences between revisions 1 and 10 (spanning 9 versions)
Revision 1 as of 2010-05-08 20:27:44
Size: 632
Editor: SheenaSmith
Comment: create page, add content (Wed Mar 10 ver; changeset 4428)
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?
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
||<tablewidth="100%" style="color: #FF0000;" :> DRAFT||
Line 6: Line 5:
Use this function to ^get more information about an error^. Use this function to retrieve a message about the last error that occurred.
Line 12: Line 11:
char* SDL_GetError(void) const char* SDL_GetError(void)
Line 16: Line 15:
A pointer to (a enum? filled with) information about the specific error that occurred. 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]]().

This string is statically allocated and must not be freed by the application.
Line 20: Line 21:
You can add your code example here if (SDL_Init( SDL_INIT_EVERYTHING ) < 0) {
    // Unrecoverable error, exit here.
    printf("SDL_Init failed: %s\n", SDL_GetError());
}
Line 22: Line 26:
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.
Line 24: Line 29:
''You can add useful comments here'' It is possible for multiple errors to occur before calling [[SDL_GetError]](). Only the last error is returned.
Line 27: Line 32:
 .[[SDL_ClearError]] ???  .[[SDL_ClearError]]
.[[SDL_SetError]]

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().

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