SDL  2.0
SDL_error.h File Reference
#include "SDL_stdinc.h"
#include "begin_code.h"
#include "close_code.h"
+ Include dependency graph for SDL_error.h:
+ This graph shows which files directly or indirectly include this file:

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

Detailed Description

Simple error message routines for SDL.

Definition in file SDL_error.h.

Macro Definition Documentation

#define SDL_OutOfMemory ( )    SDL_Error(SDL_ENOMEM)

Definition at line 52 of file SDL_error.h.

Referenced by add_audio_device(), ConvertSint24ToSint32(), createFences(), createInstance(), EnsureStreamBufferSize(), findPhysicalDevice(), getSurfaceFormats(), getSwapchainImages(), IMA_ADPCM_decode(), Map1to1(), Map1toN(), MS_ADPCM_decode(), open_audio_device(), ReadChunk(), RenderDrawLinesWithRects(), RenderDrawPointsWithRects(), RLEAlphaSurface(), RLEColorkeySurface(), SDL_AddDollarGesture_one(), SDL_AddFinger(), SDL_AddHintCallback(), SDL_AddTimer(), SDL_AddTouch(), SDL_AddVideoDisplay(), SDL_AllocBlitMap(), SDL_AllocFormat(), SDL_AllocPalette(), SDL_AllocRW(), SDL_ConvertPixels_PackUVPlanes_to_NV(), SDL_ConvertPixels_RGB_to_YUV(), SDL_ConvertPixels_SplitNV_to_UVPlanes(), SDL_ConvertPixels_SwapUVPlanes(), SDL_ConvertPixels_YUV_to_RGB(), SDL_CreateCond(), SDL_CreateMutex(), SDL_CreateRGBSurfaceWithFormat(), SDL_CreateSemaphore(), SDL_CreateTexture(), SDL_CreateThreadWithStackSize(), SDL_CreateWindow(), SDL_CreateWindowFrom(), SDL_CreateWindowTexture(), SDL_GameControllerMappingForDeviceIndex(), SDL_GameControllerMappingForGUID(), SDL_GameControllerMappingForIndex(), SDL_GameControllerOpen(), SDL_Generic_SetTLSData(), SDL_GestureAddTouch(), SDL_GetWindowGammaRamp(), SDL_HapticOpen(), SDL_HapticOpenFromJoystick(), SDL_JoystickOpen(), SDL_LoadBMP_RW(), SDL_LoadFile_RW(), SDL_NewAudioStream(), SDL_NewDataQueue(), SDL_PrepareResampleFilter(), SDL_PrivateAddMappingForGUID(), SDL_PrivateGameControllerParseElement(), SDL_PrivateGetControllerGUIDFromMappingString(), SDL_PrivateGetControllerNameFromMappingString(), SDL_RenderDrawLines(), SDL_RenderDrawPoints(), SDL_RenderFillRects(), SDL_ResampleCVT(), SDL_ReserveSpaceInDataQueue(), SDL_SensorOpen(), SDL_SW_CreateYUVTexture(), SDL_SYS_CreateThread(), SDL_TLSSet(), SDL_UpdateTextureNative(), SDL_UpdateTextureYUV(), SDL_UpdateTextureYUVPlanar(), SDL_WriteToDataQueue(), SDLTest_CommonCreateState(), SW_CreateRendererForSurface(), SW_RenderDrawLines(), SW_RenderDrawPoints(), and SW_RenderFillRects().

#define SDL_Unsupported ( )    SDL_Error(SDL_UNSUPPORTED)

Definition at line 53 of file SDL_error.h.

Referenced by IOS_JoystickRumble(), SDL_AudioOpenDevice_Default(), SDL_BlendFillRect_RGB(), SDL_BlendFillRect_RGBA(), SDL_BlendPoint_RGB(), SDL_BlendPoint_RGBA(), SDL_CaptureMouse(), SDL_CreateWindowFrom(), SDL_DINPUT_HapticGetEffectStatus(), SDL_DINPUT_HapticNewEffect(), SDL_DINPUT_HapticOpen(), SDL_DINPUT_HapticOpenFromJoystick(), SDL_DINPUT_HapticPause(), SDL_DINPUT_HapticRunEffect(), SDL_DINPUT_HapticSetAutocenter(), SDL_DINPUT_HapticSetGain(), SDL_DINPUT_HapticStopAll(), SDL_DINPUT_HapticStopEffect(), SDL_DINPUT_HapticUnpause(), SDL_DINPUT_HapticUpdateEffect(), SDL_DINPUT_JoystickOpen(), SDL_DINPUT_JoystickRumble(), SDL_DINPUT_JoystickSameHaptic(), SDL_DINPUT_MaybeAddDevice(), SDL_DINPUT_MaybeRemoveDevice(), SDL_DrawPoint(), SDL_DrawPoints(), SDL_GetDisplayDPI(), SDL_GetWindowBordersSize(), SDL_GetWindowWMInfo(), SDL_GL_BindTexture(), SDL_GL_GetAttribute(), SDL_GL_SetAttribute(), SDL_GL_UnbindTexture(), SDL_RenderReadPixels(), SDL_SetRenderDrawBlendMode(), SDL_SetRenderTarget(), SDL_SetSurfaceBlendMode(), SDL_SetTextureBlendMode(), SDL_SetWindowGammaRamp(), SDL_SetWindowHitTest(), SDL_SetWindowInputFocus(), SDL_SetWindowModalFor(), SDL_SetWindowOpacity(), SDL_UpdateYUVTexture(), SDL_WarpMouseGlobal(), SDL_XINPUT_HapticGetEffectStatus(), SDL_XINPUT_HapticNewEffect(), SDL_XINPUT_HapticOpen(), SDL_XINPUT_HapticOpenFromJoystick(), SDL_XINPUT_HapticPause(), SDL_XINPUT_HapticRunEffect(), SDL_XINPUT_HapticSetAutocenter(), SDL_XINPUT_HapticSetGain(), SDL_XINPUT_HapticStopAll(), SDL_XINPUT_HapticStopEffect(), SDL_XINPUT_HapticUnpause(), SDL_XINPUT_HapticUpdateEffect(), SDL_XINPUT_JoystickOpen(), SDL_XINPUT_JoystickRumble(), SDL_XINPUT_JoystickSameHaptic(), SDL_XINPUT_MaybeAddDevice(), SDL_XINPUT_MaybeRemoveDevice(), SDLTest_GenerateSignedBoundaryValues(), and SDLTest_GenerateUnsignedBoundaryValues().

Enumeration Type Documentation

Enumerator:
SDL_ENOMEM 
SDL_EFREAD 
SDL_EFWRITE 
SDL_EFSEEK 
SDL_UNSUPPORTED 
SDL_LASTERROR 

Definition at line 55 of file SDL_error.h.

Function Documentation

void SDL_ClearError ( void  )

Definition at line 148 of file SDL_error.c.

References SDL_error::error, and SDL_GetErrBuf().

{
SDL_error *error;
error = SDL_GetErrBuf();
error->error = 0;
}
int SDL_Error ( SDL_errorcode  code)

Definition at line 158 of file SDL_error.c.

References SDL_EFREAD, SDL_EFSEEK, SDL_EFWRITE, SDL_ENOMEM, SDL_SetError, and SDL_UNSUPPORTED.

{
switch (code) {
case SDL_ENOMEM:
return SDL_SetError("Out of memory");
case SDL_EFREAD:
return SDL_SetError("Error reading from datastream");
return SDL_SetError("Error writing to datastream");
case SDL_EFSEEK:
return SDL_SetError("Error seeking in datastream");
return SDL_SetError("That operation is not supported");
default:
return SDL_SetError("Unknown SDL error");
}
}
const char* SDL_GetError ( void  )

Definition at line 140 of file SDL_error.c.

References SDL_ERRBUFIZE, and SDL_GetErrorMsg().

{
static char errmsg[SDL_ERRBUFIZE];
return SDL_GetErrorMsg(errmsg, SDL_ERRBUFIZE);
}
int SDL_SetError ( SDL_PRINTF_FORMAT_STRING const char *  fmt,
  ... 
)

Definition at line 55 of file SDL_error.c.

References SDL_error::argc, SDL_error::args, SDL_error::buf, ERR_MAX_ARGS, ERR_MAX_STRLEN, SDL_error::error, i, SDL_error::key, NULL, SDL_ERRBUFIZE, SDL_GetErrBuf(), SDL_GetErrorMsg(), SDL_LOG_CATEGORY_ERROR, SDL_LOG_PRIORITY_DEBUG, SDL_LogDebug, SDL_LogGetPriority, SDL_strlcpy, SDL_error::value_f, SDL_error::value_i, SDL_error::value_l, and SDL_error::value_ptr.

{
va_list ap;
SDL_error *error;
/* Ignore call if invalid format pointer was passed */
if (fmt == NULL) return -1;
/* Copy in the key, mark error as valid */
error = SDL_GetErrBuf();
error->error = 1;
SDL_strlcpy((char *) error->key, fmt, sizeof(error->key));
va_start(ap, fmt);
error->argc = 0;
while (*fmt) {
if (*fmt++ == '%') {
while (*fmt == '.' || (*fmt >= '0' && *fmt <= '9')) {
++fmt;
}
switch (*fmt++) {
case 0: /* Malformed format string.. */
--fmt;
break;
case 'l':
switch (*fmt++) {
case 0: /* Malformed format string.. */
--fmt;
break;
case 'i': case 'd': case 'u':
error->args[error->argc++].value_l = va_arg(ap, long);
break;
}
break;
case 'c':
case 'i':
case 'd':
case 'u':
case 'o':
case 'x':
case 'X':
error->args[error->argc++].value_i = va_arg(ap, int);
break;
case 'f':
error->args[error->argc++].value_f = va_arg(ap, double);
break;
case 'p':
error->args[error->argc++].value_ptr = va_arg(ap, void *);
break;
case 's':
{
int i = error->argc;
const char *str = va_arg(ap, const char *);
if (str == NULL)
str = "(null)";
SDL_strlcpy((char *) error->args[i].buf, str,
error->argc++;
}
break;
default:
break;
}
if (error->argc >= ERR_MAX_ARGS) {
break;
}
}
}
va_end(ap);
/* If we are in debug mode, print out an error message
* Avoid stomping on the static buffer in GetError, just
* in case this is called while processing a ShowMessageBox to
* show an error already in that static buffer.
*/
char errmsg[SDL_ERRBUFIZE];
SDL_GetErrorMsg(errmsg, sizeof(errmsg));
}
return -1;
}