Serialbox  2.2.0
Data serialization library and tools for C/C++, Python and Fortran
Error-handling methods
SERIALBOX_API typedef void(* serialboxFatalErrorHandler_t )(const char *reason)
 Error handler callback.
 
SERIALBOX_API void serialboxFatalError (const char *reason)
 Report a fatal error. More...
 
SERIALBOX_API void serialboxInstallFatalErrorHandler (serialboxFatalErrorHandler_t handler)
 Install a fatal error handler. More...
 
SERIALBOX_API void serialboxResetFatalErrorHandler (void)
 Reset the fatal error handler. More...
 
void serialboxDefaultFatalErrorHandler (const char *reason)
 Emit the last error string to stderr and call exit(1)
 
SERIALBOX_API void serialboxStateErrorHandler (const char *reason)
 Store the the current state of the error which can be queried via serialboxStateErrorHandlerGetLastError.
 
SERIALBOX_API int serialboxStateErrorHandlerHasError (void)
 Check the current error state. More...
 
SERIALBOX_API char * serialboxStateErrorHandlerGetErrorMessage (void)
 Query the current error state. More...
 
SERIALBOX_API void serialboxStateErrorHandlerResetState (void)
 Reset the current error state.
 

Detailed Description

Function Documentation

◆ serialboxFatalError()

SERIALBOX_API void serialboxFatalError ( const char *  reason)

Report a fatal error.

This will function will invoke the installed FatalErrorHandler.

See also
serialboxInstallFatalErrorHandler

Definition at line 36 of file ErrorHandling.cpp.

◆ serialboxInstallFatalErrorHandler()

SERIALBOX_API void serialboxInstallFatalErrorHandler ( serialboxFatalErrorHandler_t  handler)

Install a fatal error handler.

By default, if Serialbox detects a fatal error it will emit the last error string to stderr and call exit(1).

This may not be appropriate in some contexts. For example, the Python module might want to translate the errror into an exception. This function allows you to install a callback that will be invoked after a fatal error occurred.

Definition at line 27 of file ErrorHandling.cpp.

◆ serialboxResetFatalErrorHandler()

SERIALBOX_API void serialboxResetFatalErrorHandler ( void  )

Reset the fatal error handler.

This resets Serialbox's fatal error handling behavior to the default.

Definition at line 32 of file ErrorHandling.cpp.

◆ serialboxStateErrorHandlerGetErrorMessage()

SERIALBOX_API char* serialboxStateErrorHandlerGetErrorMessage ( void  )

Query the current error state.

This function requires to set the ErrorHandler to serialboxStateErrorHandler.

Returns
newly allocated char* with the current error message

Definition at line 69 of file ErrorHandling.cpp.

◆ serialboxStateErrorHandlerHasError()

SERIALBOX_API int serialboxStateErrorHandlerHasError ( void  )

Check the current error state.

This function requires to set the ErrorHandler to serialboxStateErrorHandler. To obtain the associated error message, use serialboxStateErrorHandlerGetErrorMessage.

Returns
1 if there was an error, 0 otherwise

Definition at line 67 of file ErrorHandling.cpp.