Defines | |
| #define | irplib_error_assure(CONDITION, ERROR_CODE, MSG, ACTION) |
| Generic error handling macro. | |
| #define | irplib_error_push(ec, msg) |
| Set or propagate an error. | |
| #define | irplib_error_dump(severity, trace_severity) |
| Print the error queue. | |
Functions | |
| void | irplib_error_push_macro (const char *func, cpl_error_code ec, const char *file, unsigned int line) |
| Set or propagate an error. | |
| void | irplib_error_set_msg (const char *format,...) |
| Temporarily store an error message. | |
| void | irplib_error_reset (void) |
| Reset the error state. | |
| void | irplib_error_dump_macro (const char *func, const char *file, unsigned int line, cpl_msg_severity severity, cpl_msg_severity trace_severity) |
| Print the error queue. | |
|
|
Value: do { \ if (cpl_error_get_code() != CPL_ERROR_NONE) \ { \ irplib_error_push(cpl_error_get_code(), \ ("An error occurred that was not caught: %s", \ cpl_error_get_where()) ); \ ACTION; \ } \ else if (!(CONDITION)) \ { \ irplib_error_push(ERROR_CODE, MSG); \ ACTION; \ } \ } while (0)
Useful definitions might include
#define assure(BOOL, CODE) \ irplib_error_assure(BOOL, CODE, (" "), goto cleanup) #define check(CMD) \ irplib_error_assure((CMD, cpl_error_get_code() == CPL_ERROR_NONE), \ cpl_error_get_code(), (" "), goto cleanup) #define assert(BOOL) \ irplib_error_assure(BOOL, CPL_ERROR_UNSPECIFIED, \ ("Internal error, please report to " \ PACKAGE_BUGREPORT), goto cleanup) or (same as above, but including printf-style error messages)
#define assure(BOOL, CODE, ...) \ irplib_error_assure(BOOL, CODE, (__VA_ARGS__), goto cleanup) #define check(CMD, ...) \ irplib_error_assure((CMD, cpl_error_get_code() == CPL_ERROR_NONE), \ cpl_error_get_code(), (__VA_ARGS__), goto cleanup) #define assert(BOOL, ...) \ irplib_error_assure(BOOL, CPL_ERROR_UNSPECIFIED, \ ("Internal error, please report to " \ PACKAGE_BUGREPORT " " __VA_ARGS__), goto cleanup) / * Assumes that PACKAGE_BUGREPORT contains no formatting special characters * / or
#define assure(BOOL, CODE, RETURN) \ irplib_error_assure(BOOL, CODE, (" "), return RETURN) #define assure_code(BOOL, CODE) \ irplib_error_assure(BOOL, CODE, (" "), return cpl_error_get_code()) #define skip_if(BOOL) \ irplib_error_assure(BOOL, \ cpl_error_get_code() != CPL_ERROR_NONE ? \ cpl_error_get_code() : CPL_ERROR_UNSPECIFIED, \ (" "), goto cleanup) The check macros in the examples above can be used to check a command which sets the cpl_error_code in case of failure (or, by use of a comma expression, a longer sequence of such commands): check( (x = cpl_table_get_int(table, "x", 0, NULL), y = cpl_table_get_int(table, "y", 0, NULL), z = cpl_table_get_int(table, "z", 0, NULL)), ("Error reading wavelength catalogue")); The provided ERROR_CODE, MSG and ACTION are evaluated/executed only if the CONDITION evaluates to false.
Definition at line 148 of file irplib_error.h. |
|
|
Value: irplib_error_dump_macro(cpl_func, __FILE__, __LINE__, \ severity, trace_severity)
[ ERROR ] Identification loop did not converge. After 13 iterations [ ERROR ] the RMS was 20.3 pixels. (The iterative process did not converge) [ DEBUG ] in [3]uves_wavecal_identify() at uves_wavecal_identify.c :101 [ DEBUG ] [ ERROR ] Could not calibrate orders [ DEBUG ] in [2]uves_wavecal_process_chip() at uves_wavecal.c :426 [ DEBUG ] [ ERROR ] Wavelength calibration failed [ DEBUG ] in [1]uves_wavecal() at uves_wavecal.c :679 [ DEBUG ] Note that
Definition at line 217 of file irplib_error.h. Referenced by sinfo_new_cubes_coadd(). |
|
|
Value: do { \ irplib_error_set_msg msg; \ irplib_error_push_macro(cpl_func, ec, __FILE__, __LINE__); \ } while (0)
Definition at line 175 of file irplib_error.h. Referenced by irplib_framelist_contains(), irplib_framelist_extract(), irplib_framelist_extract_regexp(), irplib_framelist_load_propertylist(), and irplib_imagelist_load_framelist(). |
|
||||||||||||||||||||||||
|
Print the error queue.
irplib_error_dump()
Definition at line 404 of file irplib_error.c. |
|
||||||||||||||||||||
|
Set or propagate an error.
irplib_error_push() .The function inserts an error into the (empty or non-empty) error queue, and sets the CPL error state to ec. If the error code ec is equal to CPL_ERROR_NONE (which is not considered to be a valid error code), an error message is displayed (because it is considered a bug in the caller), and a CPL_ERROR_UNSPECIFIED is set instead.
It uses the error message previously set by Definition at line 278 of file irplib_error.c. |
|
|
Reset the error state. This function empties the error queue and resets the current cpl_error_code to CPL_ERROR_NONE. Definition at line 377 of file irplib_error.c. Referenced by irplib_reset(), and sinfo_new_stdstar(). |
|
||||||||||||
|
Temporarily store an error message.
irplib_error_push_macro() .
Neither of these functions should be called directly. Use Definition at line 356 of file irplib_error.c. |
1.4.4