Error
[Tools]

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.
Eina_Error eina_error_msg_static_register (const char *msg)
 Register a new error type, statically allocated message.
Eina_Bool eina_error_msg_modify (Eina_Error error, const char *msg)
 Change the message of an already registered message.
Eina_Error eina_error_get (void)
 Return the last set error.
void eina_error_set (Eina_Error err)
 Set the last error.
const char * eina_error_msg_get (Eina_Error error)
 Return the description of the given an error number.
Eina_Error eina_error_find (const char *msg)
 Find the Eina_Error corresponding to a message string.

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_SAFETY_ON_NULL_RETURN_VAL, 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, and EINA_SAFETY_ON_NULL_RETURN_VAL.

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

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 match msg with its corresponding Eina_Error value. If no such value is found, 0 is returned.

References EINA_SAFETY_ON_NULL_RETURN_VAL.