Error Handling
This section describes error handling in this library.More...
Enumerations
Functions
bool | ic4_get_last_error (enum IC4_ERROR *pError, char *message, size_t *message_length) Query information about the error of the previous library function call. |
Detailed Description
This section describes error handling in this library.
Most functions of this library return a bool
indicating success. Some have a designated error return value, e.g. as part of an enumeration type.
If a function fails, it sets a thread-local error value and error message. The error value and error message can be retrieved by calling the ic4_get_last_error() function.
If a function succeeds, the error value and message are cleared.
Enumeration Type Documentation
◆ IC4_ERROR
enum IC4_ERROR |
Contains the possible error codes.
Function Documentation
◆ ic4_get_last_error()
bool ic4_get_last_error | ( | enum IC4_ERROR * | pError, |
char * | message, | ||
size_t * | message_length | ||
) |
Query information about the error of the previous library function call.
- Parameters
-
[out] pError Pointer to a IC4_ERROR value to receive the error code. [out] message Pointer to a character array to receive an error message.
This parameter is optional and may beNULL
.[in,out] message_length Pointer to a size_t
describing the length of the array pointed to by message.
If message is notNULL
, this parameter is required.
The function always writes the actual number of characters required to store the error message.
- Returns
true
on success.-
If pError is
NULL
, the function fails and returnsfalse
. -
If message is not
NULL
and message_length isNULL
, the function fails and returnsfalse
. -
If *message_length is lower than the number of characters required to store the error message, the function fails and returns
false
.
- Note
- The last error information is stored in a thread-local way. A call to
ic4_get_last_error
returns error information about the previous function call that happened on the same thread thatic4_get_last_error
is called from. -
An error while calling
ic4_get_last_error
does not update the internally stored last error.