Classes | |
struct | Gan_ErrorTrace |
Stores details of single error in an error trace. More... | |
Defines | |
#define | GAN_ERR_DFL ((Gan_ErrorReporterFunc) 0) |
#define | GAN_ERR_IGN ((Gan_ErrorReporterFunc) 1) |
#define | GAN_EC_OK 0 |
#define | GAN_EC_FAIL -1 |
#define | GAN_EC_BASE 0 |
#define | GAN_EC_DFT (GAN_EC_BASE+1000) |
#define | GAN_EC_DFT_DEEP_ERROR (GAN_EC_DFT + 1) |
#define | GAN_EC_DFT_SPARE (GAN_EC_DFT + 2) |
#define | GAN_EC_DFT_BAD_N (GAN_EC_DFT + 3) |
#define | GAN_EC_DFT_EMPTY (GAN_EC_DFT + 4) |
#define | GAN_ET_YES 0 |
Values for the 'f_spare' and 'f_static_message' in the Gan_ErrorTrace structure. | |
#define | GAN_ET_NO 1 |
#define | GAN_ERROR_FAILURE 1 |
#define | GAN_ERROR_NOT_IMPLEMENTED 2 |
#define | GAN_ERROR_REF_OUTSIDE_MATRIX 3 |
#define | GAN_ERROR_CANT_REALLOC 4 |
#define | GAN_ERROR_MALLOC_FAILED 5 |
#define | GAN_ERROR_DIFFERENT_DIMS 6 |
#define | GAN_ERROR_INCOMPATIBLE 7 |
#define | GAN_ERROR_MATRIX_NOT_SQUARE 8 |
#define | GAN_ERROR_INPLACE_TRANSPOSE 9 |
#define | GAN_ERROR_INPLACE_MULTIPLY 10 |
#define | GAN_ERROR_ARRAY_TOO_SMALL 11 |
#define | GAN_ERROR_ILLEGAL_TYPE 12 |
#define | GAN_ERROR_NO_IMPLICIT_INV 13 |
#define | GAN_ERROR_CLAPACK_ILLEGAL_ARG 14 |
#define | GAN_ERROR_CBLAS_ILLEGAL_ARG 15 |
#define | GAN_ERROR_CBLAS_FAILED 16 |
#define | GAN_ERROR_NOT_POSITIVE_DEFINITE 17 |
#define | GAN_ERROR_DIVISION_BY_ZERO 18 |
#define | GAN_ERROR_SQRT_OF_NEG_NUMBER 19 |
#define | GAN_ERROR_NO_CONVERGENCE 20 |
#define | GAN_ERROR_SINGULAR_MATRIX 21 |
#define | GAN_ERROR_IMAGE_TOO_SMALL 22 |
#define | GAN_ERROR_NO_DATA 23 |
#define | GAN_ERROR_NOT_ENOUGH_DATA 24 |
#define | GAN_ERROR_OPENING_FILE 25 |
#define | GAN_ERROR_CORRUPTED_FILE 26 |
#define | GAN_ERROR_OUTSIDE_RANGE 27 |
#define | GAN_ERROR_TOO_LARGE 28 |
#define | GAN_ERROR_TOO_SMALL 29 |
#define | GAN_ERROR_TRUNCATED_FILE 30 |
#define | GAN_ERROR_NOT_INITIALISED 31 |
#define | GAN_ERROR_ILLEGAL_ARGUMENT 32 |
#define | GAN_ERROR_CCMATH_FAILED 33 |
#define | GAN_ERROR_NO_SOLUTION 34 |
#define | GAN_ERROR_READING_FROM_FILE 35 |
#define | GAN_ERROR_WRITING_TO_FILE 36 |
#define | GAN_ERROR_EXTERNAL_LIBRARY_CALL 37 |
#define | GAN_ERROR_ILLEGAL_IMAGE_TYPE 38 |
#define | GAN_ERROR_ILLEGAL_IMAGE_FORMAT 39 |
#define | GAN_ERROR_ILLEGAL_IMAGE_FILE_FORMAT 40 |
#define | GAN_ERROR_ILLEGAL_IMAGE_CHANNEL 41 |
Typedefs | |
typedef void(* | Gan_ErrorReporterFunc )(void) |
A type definition for an application supplied error handling function. | |
typedef Gan_ErrorTrace | Gan_ErrorTrace |
Stores details of single error in an error trace. | |
Enumerations | |
enum | Gan_TraceMode { GAN_ERR_TRACE_OFF, GAN_ERR_TRACE_ON } |
Error trace on/off. More... | |
Functions | |
Gan_ErrorReporterFunc | gan_err_set_reporter (Gan_ErrorReporterFunc app_error_reporter) |
Installs an error reporter. | |
Gan_ErrorReporterFunc | gan_err_get_reporter (void) |
Returns current error reporter. | |
int | gan_err_register_fileline (const char *func_name, int err_code, const char *file_name, int line_number, const char *message, int number) |
Registers occurence of an error. | |
void | gan_err_report (void) |
Invokes current error reporter. | |
void | gan_err_set_trace (Gan_TraceMode trace_mode) |
Enable or disable use of trace to store error details. | |
void | gan_err_flush_trace (void) |
Flush all errors in trace. | |
int | gan_err_get_error_count (void) |
Gets the number of errors in error trace. | |
int | gan_err_get_error (int n, const char **func_name, int *err_code, const char **file_name, int *line_number, const char **message, int *number) |
Gets details of n-th error stored in the error trace. | |
void | gan_err_register (const char *func_name, int err_code, const char *message) |
Macro: Registers an error. | |
void | gan_err_register_with_number (const char *func_name, int err_code, const char *message, int number) |
Macro: Registers an error.with a number attached. | |
Gan_Bool | gan_err_test_bool (Gan_Bool test, char *funcname, int code, char *message) |
Macro: Tests expression, fails and invokes error handler if false. | |
int | gan_err_test_int (Gan_Bool test, char *funcname, int code, char *message) |
Tests expression, fails and invokes error handler if false. | |
int | gan_err_test_uint (Gan_Bool test, char *funcname, int code, char *message) |
Macro: Tests expression, fails and invokes error handler if false. | |
void * | gan_err_test_ptr (Gan_Bool test, char *funcname, int code, char *message) |
Macro: Tests expression, fails and invokes error handler if false. | |
double | gan_err_test_double (Gan_Bool test, char *funcname, int code, char *message) |
Macro: Tests expression, fails and invokes error handler if false. | |
float | gan_err_test_float (Gan_Bool test, char *funcname, int code, char *message) |
Macro: Tests expression, fails and invokes error handler if false. | |
Gan_ErrorTrace * | gan_et_push (Gan_ErrorTrace *et_top, const char *func_name, int err_code, const char *file_name, int line_number, const char *message, int number) |
Pushes a new error recorded onto error trace. | |
int | gan_et_get_record_count (Gan_ErrorTrace *et_record) |
Counts number of records in trace from specified starting point. | |
Gan_ErrorTrace * | gan_et_get_record_next (Gan_ErrorTrace *et_record) |
Returns pointer to next non-spare error record after et_record. | |
Gan_ErrorTrace * | gan_et_get_record_first (Gan_ErrorTrace *et_record) |
Returns pointer to first non-spare error record from et_record. | |
Gan_ErrorTrace * | gan_et_flush_trace (Gan_ErrorTrace *a_record) |
Flush all errors in error trace. | |
const char * | gan_err_string (int error_code) |
Returns error message corresponding to given error code. | |
const char * | gan_err_string_at_lowest_level (void) |
|
Default error codes used within the error module. |
|
Defines to specify error reporting behaviour. Used by gan_err_set_reporter(). |
|
A type definition for an application supplied error handling function. Modelled after __kernel_signhandler_t in /usr/include/linux/posix/signal.h |
|
Stores details of single error in an error trace. Error trace is a last in, first out stack of structures containing details of recorded errors. The stack is implemented as a linked list that is traversed by following 'prev' links. The bottom (oldest) and 2nd to bottom record of the error trace are statically allocated, while all others are dynamically allocated (malloc'd). Important that gan_et_flush doesn't try to free() the statically allocated records.
The text message pointed to by "message" normally resides in a dynamically allocated char array, except for the deep error message which resides in a static char array. Therefore if the error code is EC_DFT_DEEP_ERROR, then the message char array should never be subjected to |
|
Error trace on/off. A Trace is a data structure containing complete history of error information collected from the time the initiating error occurs, to the time it unwinds to the application. GAN_ERR_TRACE_ON Indicates that a trace structure is built and that the error details are transfered to the application using gan_err_report(). The function gan_err_register() adds an error to the trace. GAN_ERR_TRACE_OFF Indicates that no trace structure be constructed. Instead error details are reported immediately during gan_err_register(). |
|
Flush all errors in trace.
|
|
Gets details of n-th error stored in the error trace.
NULL , then those details are not returned.Gets details of n-th error. n=1 refers to the most recent error registered in error trace. Usually gan_err_get_error_count() is called to obtain the number of error records in the trace. Return values:
|
|
Gets the number of errors in error trace.
|
|
Returns current error reporter.
|
|
Macro: Registers an error.
|
|
Registers occurence of an error.
If the trace mode is #GAN_ERR_TRACE_OFF, this function causes the current error reporter to called immediately. If the trace mode is #GAN_ERR_TRACE_ON, this function causes the details of the error to be placed onto an error trace. The error details are reported in "batch" at a later time upon invokation of gan_err_report().
|
|
Macro: Registers an error.with a number attached.
|
|
Invokes current error reporter.
This function is automatically called from gan_err_register_fileline() when trace mode is OFF.
|
|
Installs an error reporter.
If ((Gan_ErrorReporterFunc) 0) is provided, then the default error reporter (see below) is installed.
|
|
Enable or disable use of trace to store error details.
|
|
Returns error message corresponding to given error code.
|
|
Macro: Tests expression, fails and invokes error handler if false.
|
|
Macro: Tests expression, fails and invokes error handler if false.
DBL_MAX is returned by the calling function. If NDEBUG is defined, the test is ignored.
|
|
Macro: Tests expression, fails and invokes error handler if false.
FLT_MAX is returned by the calling function. If NDEBUG is defined, the test is ignored.
|
|
Tests expression, fails and invokes error handler if false.
NDEBUG is defined, the test is ignored.
|
|
Macro: Tests expression, fails and invokes error handler if false.
NULL is returned by the calling function. If NDEBUG is defined, the test is ignored.
|
|
Macro: Tests expression, fails and invokes error handler if false.
UINT_MAX is returned by the calling function. If NDEBUG is defined, the test is ignored.
|
|
Flush all errors in error trace.
Don't free free_me, but mark it spare, and continue |
|
Counts number of records in trace from specified starting point.
|
|
Returns pointer to first non-spare error record from et_record.
|
|
Returns pointer to next non-spare error record after et_record.
|
|
Pushes a new error recorded onto error trace.
A deep error is treated no differently from any other error, except that the reserved records are used. Therefore, even if the trace registers a deep error, gan_et_push() will attempt to register subsequent errors if memory allows. Each time a deep error occurs, gan_et_push() will attempt to register a deep error. Deep error that follow a normal error will always succeed in being registered. A deep error that follows a deep error may not succeed in being registered because of memory constraints -- however, the top of the trace will nevertheless show that the most recent error was a deep error. Errors requested to be registered while no system memory exists will be lost permanently. The oldest two records of the LIFO stack are statically allocated. This ensures that at any time a deep error can be registered. gan_et_push() or any other function in the exception handling module makes no attempt to free memory for the purpose of avoid a deep error. Memory management firmly rest with an external component (i.e. library or application). Such behaviour is consistent with the policy that the application (or library) is the master and the exception handling module is the slave. The role of the exception module is to provide full error information to the application, so that the application has the opportunity to handle the error in a contextually meaningful way. The psuedo code for handling deep errors is as follows: ----------------------------------------------------------------------- gan_et_push() Have 2 records spare? yes: register_error no: try to allocate records so that we have 2 spare on error: deep_error register_error ----------------------------------------------------------------------- register_error() (into second spare) do the best to furnish info into 2nd spare record on error: leave the error message part blank deep_error() mark 2nd record as 'not spare' allocate a new record and put at top of stack on error: deep_error() ----------------------------------------------------------------------- deep_error() Have 1 spare record (in which to write deep error) yes: write deep error into spare record no : do nothing, return |