lib/error.h File Reference


Detailed Description

C Error handling in Lumiera, header.

Definition in file error.h.

#include <nobug.h>
#include <stdlib.h>

Include dependency graph for error.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define LUMIERA_DIE(err)   do { NOBUG_ERROR(NOBUG_ON, "Fatal Error: %s ", strchr(LUMIERA_ERROR_##err, ':')); abort(); } while(0)
 Abort unconditionally with a 'Fatal Error!' message.
#define LUMIERA_ERROR_DECLARE(err)   extern lumiera_err LUMIERA_ERROR_##err
 Forward declare an error constant.
#define LUMIERA_ERROR_DEFINE(err, msg)   lumiera_err LUMIERA_ERROR_##err = "LUMIERA_ERROR_" #err ":" msg
 Definition and initialization of an error constant.
#define LUMIERA_ERROR_SET(flag, err)
 Helper macro to raise an error for the current thread.

Typedefs

typedef const char * lumiera_err

Functions

lumiera_err lumiera_error (void)
 Get and clear current error state.
 LUMIERA_ERROR_DECLARE (ERRNO)
lumiera_err lumiera_error_peek (void)
 Check current error state without clearing it Please avoid this function and use lumiera_error() if possible.
lumiera_err lumiera_error_set (lumiera_err err)
 Set error state for the current thread.


Define Documentation

#define LUMIERA_DIE ( err   )     do { NOBUG_ERROR(NOBUG_ON, "Fatal Error: %s ", strchr(LUMIERA_ERROR_##err, ':')); abort(); } while(0)

Abort unconditionally with a 'Fatal Error!' message.

This macro is used whenever the program end up in a invalid state from which no runtime recovery is possible

Definition at line 44 of file error.h.

Referenced by lumiera_calloc(), lumiera_condition_destroy(), lumiera_filedescriptor_registry_init(), lumiera_interfaceregistry_init(), lumiera_malloc(), lumiera_mutex_destroy(), lumiera_plugin_discover(), lumiera_realloc(), lumiera_reccondition_destroy(), lumiera_rwlock_destroy(), and lumiera_strndup().

#define LUMIERA_ERROR_DECLARE ( err   )     extern lumiera_err LUMIERA_ERROR_##err

Forward declare an error constant.

This macro eases the error declaration in header files

Parameters:
err name of the error without the 'LUMIERA_ERROR_' prefix (example: NO_MEMORY)

Definition at line 52 of file error.h.

#define LUMIERA_ERROR_DEFINE ( err,
msg   )     lumiera_err LUMIERA_ERROR_##err = "LUMIERA_ERROR_" #err ":" msg

Definition and initialization of an error constant.

This macro eases the error definition in implementation files

Parameters:
err name of the error without the 'LUMIERA_ERROR_' prefix (example: NO_MEMORY)
msg message describing the error in plain english (example: "memory allocation failed")

Definition at line 61 of file error.h.

#define LUMIERA_ERROR_SET ( flag,
err   ) 

Value:

(({ERROR (flag, "%s", strchr(LUMIERA_ERROR_##err, ':')+1);}), \
lumiera_error_set(LUMIERA_ERROR_##err))
Helper macro to raise an error for the current thread.

This macro eases setting an error. It adds NoBug logging support to the low level error handling.

Parameters:
flag NoBug flag describing the subsystem where the error was raised
err name of the error without the 'LUMIERA_ERROR_' prefix (example: NO_MEMORY)

Definition at line 70 of file error.h.

Referenced by lumiera_config_number_get(), lumiera_config_wordlist_get(), lumiera_file_mmapings(), lumiera_filedescriptor_acquire(), lumiera_filehandlecache_handle_acquire(), lumiera_mmap_init(), lumiera_plugin_register(), and scan_string().


Function Documentation

lumiera_err lumiera_error_set ( lumiera_err  err  ) 

Set error state for the current thread.

If the error state of the current thread was cleared, then set it, else preserve the old state.

Parameters:
nerr name of the error with 'LUMIERA_ERROR_' prefix (example: LUMIERA_ERROR_NO_MEMORY)
Returns:
old state, that is NULL for success, when the state was cleared and a pointer to a pending error when the error state was already set

Definition at line 50 of file error.c.

Referenced by lumiera::Error::Error().

Here is the caller graph for this function:

lumiera_err lumiera_error ( void   ) 

Get and clear current error state.

This function clears the error state, if it needs to be reused, one has to store it in a temporary variable.

Returns:
pointer to any pending error of this thread, NULL if no error is pending

Definition at line 64 of file error.c.

Referenced by test::Suite::describe(), and lumiera_plugin_init().

Here is the caller graph for this function:

lumiera_err lumiera_error_peek ( void   ) 

Check current error state without clearing it Please avoid this function and use lumiera_error() if possible.

Errors must be cleared else certain parts of the application refuse to cooperate with you. This shall only be used to decide if one wants to barf out of a loop or subroutine to deliver the error to a higher level.

Returns:
pointer to any pending error of this thread, NULL if no error is pending

Definition at line 77 of file error.c.

Referenced by lumiera_plugin_discover(), and lumiera_plugin_register().

Here is the caller graph for this function:


Generated on Tue Jan 6 17:20:48 2009 for Lumiera by  doxygen 1.5.6