EM-ODP  3.7.0
Event Machine on ODP
Error management

Error/Exception management. More...

Typedefs

typedef em_status_t(* em_error_handler_t) (em_eo_t eo, em_status_t error, em_escope_t escope, va_list args)
 

Functions

em_status_t em_register_error_handler (em_error_handler_t handler)
 
em_status_t em_unregister_error_handler (void)
 
void em_error (em_status_t error, em_escope_t escope,...)
 

Detailed Description

Error/Exception management.

EM provides two basic mechanisms to manage operational exceptions

  1. Return value
    • Most API calls return a status which can be checked by the application
  2. Error handler
    • An optional error handler function can be registered. The given function is called by the EM implementation when an error occurs. This makes it possible to centralize the error management or even modify some API behavior as an error handler can modify the original API call return value as well. For instance, a global error handler could modify the em_send() behavior in such a way that the application never has to check the return value by catching all errors, fixing them (like deallocating event on failed send) and returning EM_OK.
    • There can be one global error handler and additionally one per each EO.

Typedef Documentation

◆ em_error_handler_t

typedef em_status_t(* em_error_handler_t) (em_eo_t eo, em_status_t error, em_escope_t escope, va_list args)

Error handler prototype

The error handler is called after EM notices an error or the user has called em_error().

The user can register EO specific and/or EM global error handlers. When an error occurs, EM calls the EO specific error handler, if registered. If there's no EO specific handler registered or the error occurs outside of an EO context, EM calls the global error handler.

The error handler is called with the original error code (that's about to be returned) from the API call or em_error(). The error scope identifies the source of the error and how the error code and the variable arguments should be interpreted (number of arguments and types) in an implementation specific way.

Parameters
eoExecution object id
errorThe error code
escopeError scope. Identifies the scope for interpreting the error code and variable arguments.
argsVariable number and type of arguments
Returns
The function may not return depending on implementation, error code or error scope. If it returns, it can return the original or modified error code or even EM_OK if it was able to fix the problem.
See also
em_register_error_handler(), em_eo_register_error_handler()

Definition at line 94 of file event_machine_error.h.

Function Documentation

◆ em_error()

void em_error ( em_status_t  error,
em_escope_t  escope,
  ... 
)

Report an error.

Reported errors are handled by the appropriate (EO specific or global) error handler.

Depending on the error/scope/implementation, the function call may not return.

Parameters
errorError code
escopeError scope. Identifies the scope for interpreting the error code and the variable arguments.
...Variable number and type of arguments
See also
em_register_error_handler(), em_error_handler_t()
Examples
error.c.

Definition at line 66 of file event_machine_error.c.

◆ em_register_error_handler()

em_status_t em_register_error_handler ( em_error_handler_t  handler)

Register a global error handler.

The global error handler is called on EM errors or by em_error() calls, except when running in an EO context with an EO specific error handler registered (in which case the EO specific error handler takes precedence). Note, the provided function will override any previously registered global error handler. The EM default global error handler is used when no user provided global error handler is registered.

Parameters
handlerError handler.
Returns
EM_OK if successful.
See also
em_eo_register_error_handler(), em_unregister_error_handler(), em_error_handler_t()
Examples
api_hooks.c, atomic_processing_end.c, dispatcher_callback.c, error.c, event_group.c, event_group_abort.c, event_group_assign_end.c, event_group_chaining.c, fractal.c, hello.c, loop.c, loop_multircv.c, loop_refs.c, loop_vectors.c, ordered.c, pairs.c, pool_perf.c, queue_group.c, queue_groups.c, queue_types_ag.c, queue_types_local.c, queues.c, queues_local.c, queues_output.c, queues_unscheduled.c, scheduling_latency.c, send_multi.c, timer_hello.c, timer_test.c, timer_test_periodic.c, and timer_test_ring.c.

Definition at line 34 of file event_machine_error.c.

◆ em_unregister_error_handler()