ilGetError returns the value of the last error on the error stack. If no error has occurred, IL_NO_ERROR is returned. Initially, the error stack is set to IL_NO_ERROR. When ilGetError is called, the last error on the error stack is "popped off". Errors that occur in ILU and ILUT are also reported through ilGetError. ilGetError only returns something other than IL_NO_ERROR if detectable errors have occurred. A simple (but potentially deadly) use of ilGetError could be:
- while (ilGetError() != IL_NO_ERROR);
This is alright when very simple operations have been performed, but a more robust solution is needed to check for harmful errors, such as IL_OUT_OF_MEMORY. A list of errors that may be returned follow:
- IL_NO_ERROR
- No detectable error has occured.
- IL_INVALID_ENUM, ILU_INVALID_ENUM, ILUT_INVALID_ENUM
- An unacceptable enumerated value was passed to a function.
- IL_OUT_OF_MEMORY, ILU_OUT_OF_MEMORY, ILUT_OUT_OF_MEMORY
- Could not allocate enough memory in an operation.
- IL_FORMAT_NOT_SUPPORTED
- The format a function tried to use was not able to be used by that function.
- IL_INTERNAL_ERROR, ILU_INTERNAL_ERROR
- A serious error has occurred. Please e-mail DooMWiz with the conditions leading up to this error being reported.
- IL_INVALID_VALUE, ILU_INVALID_VALUE, ILUT_INVALID_VALUE
- An invalid value was passed to a function or was in a file.
- IL_ILLEGAL_OPERATION, ILU_ILLEGAL_OPERATION, ILUT_ILLEGAL_OPERATION
- The operation attempted is not allowable in the current state. The function returns with no ill side effects.
- IL_ILLEGAL_FILE_VALUE
- An illegal value was found in a file trying to be loaded.
- IL_INVALID_FILE_HEADER
- A file's header was incorrect.
- IL_INVALID_PARAM, ILU_INVALID_PARAM, ILUT_INVALID_PARAM
- An invalid parameter was passed to a function, such as a NULL pointer.
- IL_COULD_NOT_OPEN_FILE, ILUT_COULD_NOT_OPEN_FILE
- Could not open the file specified. The file may already be open by another app or may not exist.
- IL_INVALID_EXTENSION
- The extension of the specified filename was not correct for the type of image-loading function.
- IL_FILE_ALREADY_EXISTS
- The filename specified already belongs to another file. To overwrite files by default, call ilEnable with the IL_FILE_OVERWRITE parameter.
- IL_OUT_FORMAT_SAME
- Tried to convert an image from its format to the same format.
- IL_STACK_OVERFLOW, ILUT_STACK_OVERFLOW
- One of the internal stacks was already filled, and the user tried to add on to the full stack.
- IL_STACK_UNDERFLOW, ILUT_STACK_UNDERFLOW
- One of the internal stacks was empty, and the user tried to empty the already empty stack.
- IL_INVALID_CONVERSION
- An invalid conversion attempt was tried.
- IL_LIB_JPEG_ERROR
- An error occurred in the libjpeg library.
- IL_LIB_PNG_ERROR
- An error occurred in the libpng library.
- IL_UNKNOWN_ERROR
- No function sets this yet, but it is possible (not probable) it may be used in the future.
- ILUT_NOT_SUPPORTED
- A type is valid but not supported in the current build.