1 /** \defgroup error Error handling 2 * 3 * Errors are negative numbers. Positive numbers are reserved for 4 * other purposes (like returning number of samples written) 5 * 6 * \addtogroup error 7 * @{ 8 */ 9 10 #ifndef _LTFAT_ERRNO_H 11 #define _LTFAT_ERRNO_H 12 #include "basicmacros.h" 13 14 enum ltfaterr_status 15 { 16 // General 17 LTFATERR_SUCCESS = 0, 18 LTFATERR_FAILED = -1, 19 LTFATERR_NOMEM = -2, 20 LTFATERR_INITFAILED = -3, 21 LTFATERR_NULLPOINTER = -4, 22 LTFATERR_EMPTY = -5, 23 LTFATERR_BADARG = -6, 24 LTFATERR_NOTPOSARG = -7, 25 LTFATERR_NOTINRANGE = -8, 26 LTFATERR_OVERFLOW = -9, 27 LTFATERR_UNDERFLOW = -10, 28 LTFATERR_CANNOTHAPPEN = -11, 29 LTFATERR_BADSIZE = -12, // Array size is wrong 30 LTFATERR_BADREQSIZE = -13, // Output array size is wrong 31 LTFATERR_NOTSUPPORTED = -14, 32 // Specific 33 LTFATERR_BADTRALEN = -99, 34 LTFATERR_NOTAFRAME = -100, 35 LTFATERR_NOTPAINLESS = -101, 36 LTFATERR_NOTPOSDEFMATRIX= -102, 37 // Missing components 38 LTFATERR_NOBLASLAPACK = -200 39 }; 40 41 42 /** Function signature for a custom error handler 43 * 44 * \param[in] ltfat_errno Status code of the error 45 * \param[in] file Filename 46 * \param[in] line Line 47 * \param[in] funcname Function name 48 * \param[out] reason Error message 49 */ 50 typedef void ltfat_error_handler_t (int ltfat_errno, const char* file, int line, 51 const char* funcname, const char* reason); 52 53 54 /** Register a new error handler 55 * 56 * Default error handling behavior can be recovered by passing NULL. 57 * \returns Old error handler 58 */ 59 LTFAT_API ltfat_error_handler_t* 60 ltfat_set_error_handler (ltfat_error_handler_t* new_handler); 61 62 /** Disable error handling 63 * \returns Old error handler 64 */ 65 LTFAT_API ltfat_error_handler_t* 66 ltfat_set_error_handler_off (void); 67 68 /** @} */ 69 70 LTFAT_API void 71 ltfat_error (int ltfat_errno, const char * file, int line, 72 const char* funcname, const char * format, ...); 73 74 75 #endif 76