Lumiera
0.pre.03
»edit your freedom«
|
Go to the source code of this file.
implementation of C-style error handling in Lumiera.
This implementation is based on a thread local error flag. C++ code uses a custom exception hierarchy, which automatically sets the error flag whenever an exception is thrown.
Definition in file error-state.c.
Classes | |
struct | lumiera_errorcontext |
Holding error and some context data. More... | |
Typedefs | |
typedef lumiera_errorcontext * | LumieraErrorcontext |
Functions | |
lumiera_err | lumiera_error (void) |
Get and clear current error state. More... | |
LUMIERA_ERROR_DEFINE (ERRNO, "errno") | |
LUMIERA_ERROR_DEFINE (EERROR, "could not initialise error system") | |
LUMIERA_ERROR_DEFINE (UNKNOWN, "unknown error") | |
int | lumiera_error_expect (lumiera_err expected) |
Expect some error Check that the current error state matches some expectation, if true then the error state is cleared and 1 is returned, otherwise 0 is returned and the error state remains set. More... | |
const char * | lumiera_error_extra (void) |
Query the extra context for the last error. More... | |
LumieraErrorcontext | lumiera_error_get (void) |
lumiera_err | lumiera_error_peek (void) |
Check current error state without clearing it Please avoid this function and use lumiera_error() if possible. More... | |
lumiera_err | lumiera_error_set (lumiera_err nerr, const char *extra) |
Set error state for the current thread. More... | |
static void | lumiera_error_tls_delete (void *err) |
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 |
struct lumiera_errorcontext_struct |
lumiera_err lumiera_error_set | ( | lumiera_err | nerr, |
const char * | extra | ||
) |
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.
nerr | name of the error with 'LUMIERA_ERROR_' prefix (example: LUMIERA_ERROR_NO_MEMORY) |
extra | a string (possibly a constructed tmpbuf) which adds some more context to the error, can be a temporary |
Definition at line 105 of file error-state.c.
Referenced by ExceptionError_test::checkErrorFlagPropagation(), and lumiera_lockerror_set().
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.
Definition at line 124 of file error-state.c.
Referenced by OutputDirector::bringDown(), AllocatorHandle< TY >::Allocation::discard(), AdviceSystem::discardEntry(), ExecResult::ExecResult(), stage::ctrl::anonymous_namespace{ui-dispatcher.hpp}::generateErrorResponse(), HandlingPattern::invoke(), lumiera_plugin_init(), lumiera::maybeThrow(), DispatcherLoop::runSessionThread(), Provision< PStyleContext >::storeCopy(), lumiera::throwOnError(), AllocationCluster::~AllocationCluster(), and MockElm::~MockElm().
const char* lumiera_error_extra | ( | void | ) |
Query the extra context for the last error.
Definition at line 135 of file error-state.c.
Referenced by lumiera::error::detailInfo().
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.
Definition at line 142 of file error-state.c.
Referenced by ExceptionError_test::checkErrorFlagPropagation(), and GuiSubsysDescriptor::checkRunningState().
int lumiera_error_expect | ( | lumiera_err | expected | ) |
Expect some error Check that the current error state matches some expectation, if true then the error state is cleared and 1 is returned, otherwise 0 is returned and the error state remains set.
expected | error which is expected |
Definition at line 148 of file error-state.c.