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.

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.

To use the error system Eina must be initialized with eina_init() and later shut down with eina_shutdown(). Error codes are registered with eina_error_msg_register() and converted from identifier to original message string with eina_error_msg_get().

Logging functions are not in eina_error anymore, see eina_log_print() instead.


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 strdup().
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()
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()
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 freed and msg copied.

See also:
eina_error_msg_register()
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().

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

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.