Error handling and debugging module, utilities, macros and definitions. See the Error handling and Debugging topic guide for more details.
|S_NEW_ERR||Set a new error with no context.|
|S_CLR_ERR||Clear the given error.|
|S_CTX_ERR||Set a new error with a context.|
|S_FTL_ERR||Set a new fatal context error.|
|S_CHK_ERR||Check if an error has been set.|
|S_WARNING||Macro that sets a warning message.|
|S_DEBUG||Macro that sets a debug message.|
|s_set_errdbg_level||Change the debugging level.|
|s_get_errdbg_level||Get the debugging level.|
|s_set_errdbg_logger||Set the error and debugging system logger to the given one.|
|s_errdbg_on||Query whether the Error and Debugging System is activated or not.|
|s_error_str||Convert the given error code into a string representation.|
Definitions of error return codes.
Success, no errors.
An unspecified failure occurred.
A memory allocation error.
Error in function arguments.
Class/Object method does not exist.
End of file/stream.
Warning, possible error.
Error context continued.
Debug level definitions.
If the debug level is set to S_DBG_TRACE then all debug messages with a debug level equal and lower will be output to the Logging system.
No debugging output.
Basic debug level.
Verbose debug level.
All debugging logged.
Macros that sets and clears errors.
Set a new error with no context.
Set ERROR to the error code that occurred, ERROR_CODE. This macro is useful in deeply nested functions where there is not enough context to add, i.e. it is only known that an error of ERROR_CODE type occurred, but not why it occurred.
Clear the given error.
It is good practice to clear the error code (*ERROR = S_SUCCESS) at the beginning of all functions.
Set a new error with a context.
Sets ERROR to the error code that occurred, NEW_ERROR, as well as giving the error logger the function name and a variable length argument string of the context wherein this error occurred.
Set a new fatal context error.
Sets ERROR to the fatal error code that occurred, NEW_ERROR, as well as giving the error logger the function name and a variable length argument string of the context wherein this error occurred. The same as S_CTX_ERR except that if the build option SPCT_ERROR_ABORT_FATAL is set then the program is aborted.
Macro that tests for errors and sets new context based on test.
Check if an error has been set.
Test if an error has occurred (if ERROR is set, i.e. not equal to S_SUCCESS), and if so set a new context error (same as S_CTX_ERR), and return TRUE. If no error was set, (*ERROR = S_SUCCESS) then nothing is done and FALSE is returned. This macro can be used in if statements directly after calling a function with an error code parameter, testing if an error occurred, setting a new error context and executing the if statement. If no error occurred then no new context is set and the if statement is not executed.
Macro that sets warning messages.
Macro that sets a warning message.
Set a warning with the given context. The warning is logged with the given context and message.
Macro that sets a debug message.
The debug message is logged only if the given debug level is equal or lower that the set level of the Error handling and Debugging module. This level can be changed with the s_set_errdbg_level function.
Change the debugging level.
Get the debugging level.
The debugging level.
Set the error and debugging system logger to the given one.
The current logger (if any) will be freed. This is useful when the logger needs to be changed after Speect has started up.
Query whether the Error and Debugging System is activated or not.
The system can be activated/deactivate with the compile time definition of SPCT_ERROR_HANDLING. If deactivated then no logging or checking of error codes will occur.
|Return:||TRUE if activated, else FALSE.|
Convert the given error code into a string representation.
Pointer to string representation of the given error code. If the error code is unknown then “<em>Undefined error</em>” is returned.
Caller is responsible for returned character buffer’s memory.