lib/error.c File Reference


Detailed Description

C Error handling in Lumiera.

Definition in file error.c.

#include <pthread.h>
#include "lib/error.h"

Include dependency graph for error.c:

Go to the source code of this file.

Functions

lumiera_err lumiera_error (void)
 Get and clear current error state.
 LUMIERA_ERROR_DEFINE (ERRNO,"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 nerr)
 Set error state for the current thread.
static void lumiera_error_tls_init (void)

Variables

static pthread_once_t lumiera_error_initialized = PTHREAD_ONCE_INIT
static pthread_key_t lumiera_error_tls


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

00051 {
00052   pthread_once (&lumiera_error_initialized, lumiera_error_tls_init);
00053 
00054   lumiera_err err = pthread_getspecific (lumiera_error_tls);
00055   if (!err)
00056     pthread_setspecific (lumiera_error_tls, nerr);
00057 
00058   return err;
00059 }

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 63 of file error.c.

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

00064 {
00065   pthread_once (&lumiera_error_initialized, lumiera_error_tls_init);
00066 
00067   lumiera_err err = pthread_getspecific (lumiera_error_tls);
00068   if (err)
00069     pthread_setspecific (lumiera_error_tls, NULL);
00070   return err;
00071 }

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 75 of file error.c.

Referenced by lumiera_plugin_discover(), and lumiera_plugin_register().

00076 {
00077   pthread_once (&lumiera_error_initialized, lumiera_error_tls_init);
00078 
00079   return pthread_getspecific (lumiera_error_tls);
00080 }

Here is the caller graph for this function:


Generated on Fri Nov 7 22:15:16 2008 for Lumiera by  doxygen 1.5.6