41 static pthread_key_t lumiera_error_tls;
42 static pthread_once_t lumiera_error_initialized = PTHREAD_ONCE_INIT;
54 typedef lumiera_errorcontext* LumieraErrorcontext;
58 lumiera_error_tls_delete (
void*
err)
61 free (((LumieraErrorcontext)err)->extra);
66 lumiera_error_tls_init (
void)
68 if (!!pthread_key_create (&lumiera_error_tls, lumiera_error_tls_delete))
74 lumiera_error_get (
void)
76 pthread_once (&lumiera_error_initialized, lumiera_error_tls_init);
78 LumieraErrorcontext
self = pthread_getspecific (lumiera_error_tls);
82 self = malloc (
sizeof *
self);
88 pthread_setspecific (lumiera_error_tls,
self);
98 LumieraErrorcontext
self = lumiera_error_get ();
105 self->extra = strdup (extra);
117 LumieraErrorcontext
self = lumiera_error_get ();
118 lumiera_err
err =
self->err;
128 return lumiera_error_get ()->extra;
135 return lumiera_error_get ()->err;
141 LumieraErrorcontext
self = lumiera_error_get ();
142 lumiera_err
err =
self->err;
lumiera_err lumiera_error_peek(void)
Check current error state without clearing it Please avoid this function and use lumiera_error() if p...
int lumiera_error_expect(lumiera_err expected)
Expect some error Check that the current error state matches some expectation, if true then the error...
Lumiera error handling (C interface).
Holding error and some context data.
#define LUMIERA_DIE(err)
Abort unconditionally with a 'Fatal Error!' message.
lumiera_err lumiera_error(void)
Get and clear current error state.
lumiera_err lumiera_error_set(lumiera_err nerr, const char *extra)
Set error state for the current thread.
const char * lumiera_error_extra(void)
Query the extra context for the last error.
#define LUMIERA_ERROR_DEFINE(err, msg)
Definition and initialisation of an error constant.