Typedefs | Functions | Variables
Error

This group discusses the functions that provide error management for projects. More...

Typedefs

typedef int Eina_Error
 The integer type containing the error type.
 

Functions

EAPI Eina_Error eina_error_msg_register (const char *msg) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT
 Registers a new error type. More...
 
EAPI Eina_Error eina_error_msg_static_register (const char *msg) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT
 Registers a new error type, statically allocated message. More...
 
EAPI Eina_Bool eina_error_msg_modify (Eina_Error error, const char *msg) EINA_ARG_NONNULL(2)
 Changes the message of an already registered message. More...
 
EAPI Eina_Error eina_error_get (void)
 Returns the last set error. More...
 
EAPI void eina_error_set (Eina_Error err)
 Sets the last error. More...
 
EAPI const char * eina_error_msg_get (Eina_Error error) EINA_PURE
 Returns the description of the given error number. More...
 
EAPI Eina_Error eina_error_find (const char *msg) EINA_ARG_NONNULL(1) EINA_PURE
 Finds the Eina_Error corresponding to a message string. More...
 

Variables

EAPI Eina_Error EINA_ERROR_OUT_OF_MEMORY
 The error identifier corresponding to lack of memory.
 

Detailed Description

This group discusses the functions that 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 as well.

A simple example of how to use this can be seen here.

Function Documentation

§ eina_error_msg_register()

EAPI Eina_Error eina_error_msg_register ( const char *  msg)

Registers a new error type.

Parameters
[in]msgThe description of the error
It is duplicated using eina_stringshare_add().
Returns
The unique number identifier for this error

This function stores the error message described by msg in a list. The returned value is a unique identifier greater than or equal to 1. The description can be retrieved later by passing the returned value to eina_error_msg_get().

See also
eina_error_msg_static_register()

§ eina_error_msg_static_register()

EAPI Eina_Error eina_error_msg_static_register ( const char *  msg)

Registers a new error type, statically allocated message.

Parameters
[in]msgThe description of the error
This string is not duplicated and thus the given pointer should live during the usage of eina_error.
Returns
The unique number identifier for this error

This function stores the error message described by msg in a list. The returned value is a unique identifier greater than or equal to 1. The description can be retrieved later by passing the returned value to eina_error_msg_get().

See also
eina_error_msg_register()

Referenced by elm_photocam_bounce_get(), and efl::eina::unknown_error().

§ eina_error_msg_modify()

EAPI Eina_Bool eina_error_msg_modify ( Eina_Error  error,
const char *  msg 
)

Changes the message of an already registered message.

Parameters
[in]errorThe Eina_Error to change the message of
[in]msgThe description of the error
This string is duplicated only if the error is registered with eina_error_msg_register, otherwise it must remain intact for the duration.
Returns
EINA_TRUE if successful, otherwise EINA_FALSE on error

This function modifies the message associated with error and changes it to msg. If the error is previously registered by eina_error_msg_static_register then the string is not duplicated, otherwise the previous message is unrefed and msg is copied.

See also
eina_error_msg_register()

§ eina_error_get()

EAPI Eina_Error eina_error_get ( void  )

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

Note
This function is thread safe
Since
1.10, but slower to use.

References eina_main_loop_is(), and eina_tls_get().

Referenced by efl::eina::get_error_code(), efl::eina::get_error_code_enum(), and efl::eina::get_error_condition().

§ eina_error_set()

EAPI void eina_error_set ( Eina_Error  err)

Sets the last error.

Parameters
[in]errThe error identifier

This function sets the last error identifier. The last error can be retrieved by eina_error_get().

Note
This is also used to clear previous errors, in which case err should be 0.
This function is thread safe
Since
1.10, but slower to use.

References eina_main_loop_is(), and eina_tls_set().

Referenced by _eina_safety_error(), edje_edit_state_image_border_fill_set(), edje_edit_state_image_border_set(), edje_edit_state_image_set(), eo_dbg_info_free(), efl::eina::get_error_code(), efl::eina::get_error_condition(), and efl::eina::set_error_code().

§ eina_error_msg_get()

EAPI const char* eina_error_msg_get ( Eina_Error  error)

Returns the description of the given error number.

Parameters
[in]errorThe error number
Returns
The description of the error

This function returns the description of an error that has been registered by eina_error_msg_register(). If an incorrect error is given, then NULL is returned.

Referenced by efl::eina::error_category::message().

§ eina_error_find()

EAPI Eina_Error eina_error_find ( const char *  msg)

Finds the Eina_Error corresponding to a message string.

Parameters
[in]msgThe error message string to match (NOT NULL)
Returns
The Eina_Error matching msg, otherwise 0 on failure

This function attempts to match msg with its corresponding Eina_Error value. If no such value is found, 0 is returned.