50 static pthread_key_t lumiera_error_tls;
51 static pthread_once_t lumiera_error_initialized = PTHREAD_ONCE_INIT;
63 typedef lumiera_errorcontext* LumieraErrorcontext;
67 lumiera_error_tls_delete (
void*
err)
70 free (((LumieraErrorcontext)err)->extra);
75 lumiera_error_tls_init (
void)
77 if (!!pthread_key_create (&lumiera_error_tls, lumiera_error_tls_delete))
83 lumiera_error_get (
void)
85 pthread_once (&lumiera_error_initialized, lumiera_error_tls_init);
87 LumieraErrorcontext
self = pthread_getspecific (lumiera_error_tls);
91 self = malloc (
sizeof *
self);
97 pthread_setspecific (lumiera_error_tls,
self);
107 LumieraErrorcontext
self = lumiera_error_get ();
114 self->extra = strdup (extra);
126 LumieraErrorcontext
self = lumiera_error_get ();
127 lumiera_err
err =
self->err;
137 return lumiera_error_get ()->extra;
144 return lumiera_error_get ()->err;
150 LumieraErrorcontext
self = lumiera_error_get ();
151 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.