These functions provide error management for projects. More...
Typedefs | |
typedef int | Eina_Error |
Error type. | |
Functions | |
Eina_Error | eina_error_msg_register (const char *msg) |
Register a new error type. More... | |
Eina_Error | eina_error_msg_static_register (const char *msg) |
Register a new error type, statically allocated message. More... | |
Eina_Bool | eina_error_msg_modify (Eina_Error error, const char *msg) |
Change the message of an already registered message. More... | |
Eina_Error | eina_error_get (void) |
Return the last set error. More... | |
void | eina_error_set (Eina_Error err) |
Set the last error. More... | |
const char * | eina_error_msg_get (Eina_Error error) |
Return the description of the given an error number. More... | |
Eina_Error | eina_error_find (const char *msg) |
Find the Eina_Error corresponding to a message string. More... | |
Variables | |
Eina_Error | EINA_ERROR_OUT_OF_MEMORY |
Error identifier corresponding to a lack of memory. | |
Detailed Description
These functions provide error management for projects.
The Eina error module provides a way to manage errors in a simple but powerful way in libraries and modules. It is also used in Eina itself. Similar to libC's errno
and strerror() facilities, this is extensible and recommended for other libraries and applications.
A simple example of how to use this can be seen here.
Function Documentation
Eina_Error eina_error_msg_register | ( | const char * | msg) |
Register a new error type.
- Parameters
-
msg The description of the error. It will be duplicated using eina_stringshare_add().
- Returns
- The unique number identifier for this error.
This function stores in a list the error message described by msg
. The returned value is a unique identifier greater or equal than 1. The description can be retrieve later by passing to eina_error_msg_get() the returned value.
- See Also
- eina_error_msg_static_register()
References eina_stringshare_add(), and EINA_TRUE.
Eina_Error eina_error_msg_static_register | ( | const char * | msg) |
Register a new error type, statically allocated message.
- Parameters
-
msg The description of the error. This string will not be duplicated and thus the given pointer should live during usage of eina_error.
- Returns
- The unique number identifier for this error.
This function stores in a list the error message described by msg
. The returned value is a unique identifier greater or equal than 1. The description can be retrieve later by passing to eina_error_msg_get() the returned value.
- See Also
- eina_error_msg_register()
References EINA_FALSE.
Referenced by eina_init().
Eina_Bool eina_error_msg_modify | ( | Eina_Error | error, |
const char * | msg | ||
) |
Change the message of an already registered message.
- Parameters
-
error The Eina_Error to change the message of msg The description of the error. This string will be duplicated only if the error was registered with eina_error_msg_register otherwise it must remain intact for the duration.
- Returns
- EINA_TRUE if successful, EINA_FALSE on error
This function modifies the message associated with error
and changes it to msg
. If the error was previously registered by eina_error_msg_static_register then the string will not be duplicated, otherwise the previous message will be unrefed and msg
copied.
- See Also
- eina_error_msg_register()
References EINA_FALSE, eina_stringshare_add(), eina_stringshare_del(), and EINA_TRUE.
Eina_Error eina_error_get | ( | void | ) |
Return the last set error.
- Returns
- The last error.
This function returns the last error set by eina_error_set(). The description of the message is returned by eina_error_msg_get().
- Examples:
- eina_hash_01.c, eina_hash_03.c, eina_hash_04.c, eina_hash_05.c, eina_hash_06.c, and eina_hash_07.c.
void eina_error_set | ( | Eina_Error | err) |
Set the last error.
- Parameters
-
err The error identifier.
This function sets the last error identifier. The last error can be retrieved with eina_error_get().
- Note
- This is also used to clear previous errors, in that case
err
should be0
.
- Examples:
- eina_hash_01.c, eina_hash_03.c, eina_hash_04.c, eina_hash_05.c, eina_hash_06.c, eina_hash_07.c, and eina_value_03.c.
Referenced by eina_array_accessor_new(), eina_array_iterator_new(), eina_array_new(), eina_array_remove(), eina_benchmark_new(), eina_benchmark_register(), eina_convert_atod(), eina_counter_new(), eina_counter_start(), eina_hash_iterator_data_new(), eina_hash_iterator_key_new(), eina_hash_iterator_tuple_new(), eina_hash_new(), eina_inarray_accessor_new(), eina_inarray_iterator_new(), eina_inarray_iterator_reversed_new(), eina_inarray_new(), eina_inlist_accessor_new(), eina_inlist_iterator_new(), eina_inlist_remove(), eina_list_accessor_new(), eina_list_append(), eina_list_append_relative_list(), eina_list_iterator_new(), eina_list_iterator_reversed_new(), eina_list_prepend(), eina_list_prepend_relative_list(), eina_magic_fail(), eina_matrixsparse_iterator_complete_new(), eina_matrixsparse_iterator_new(), eina_matrixsparse_new(), eina_module_load(), eina_tile_grid_slicer_iterator_new(), and eina_value_new().
const char* eina_error_msg_get | ( | Eina_Error | error) |
Return the description of the given an error number.
- Parameters
-
error The error number.
- Returns
- The description of the error.
This function returns the description of an error that has been registered with eina_error_msg_register(). If an incorrect error is given, then NULL
is returned.
Eina_Error eina_error_find | ( | const char * | msg) |
Find the Eina_Error corresponding to a message string.
- Parameters
-
msg The error message string to match (NOT NULL
)
- Returns
- The Eina_Error matching
msg
, or 0 on failure This function attempts to matchmsg
with its corresponding Eina_Error value. If no such value is found, 0 is returned.