|
#define | FNFT__WARN(msg) fnft__warn_aux(__func__, __LINE__, msg); |
|
#define | FNFT__E_NOMEM FNFT__ERRMSG(FNFT_EC_NOMEM, "Out of memory.") |
|
#define | FNFT__E_INVALID_ARGUMENT(name) FNFT__ERRMSG(FNFT_EC_INVALID_ARGUMENT, FNFT__E_INVALID_ARGUMENT_(name)) |
|
#define | FNFT__E_SUBROUTINE(ec) FNFT__ERRMSG(-abs(ec), "Subroutine failure.") |
|
#define | FNFT__E_DIV_BY_ZERO FNFT__ERRMSG(FNFT_EC_DIV_BY_ZERO, "Division by zero.") |
|
#define | FNFT__E_TEST_FAILED FNFT__ERRMSG(FNFT_EC_TEST_FAILED, "Test failed.") |
|
#define | FNFT__E_OTHER(msg) FNFT__ERRMSG(FNFT_EC_OTHER, msg) |
|
#define | FNFT__E_NOT_YET_IMPLEMENTED(name, msg) FNFT__ERRMSG(FNFT_EC_NOT_YET_IMPLEMENTED, FNFT__E_NOT_YET_IMPLEMENTED_(name,msg)) |
|
#define | FNFT__E_SANITY_CHECK_FAILED(msg) FNFT__ERRMSG(FNFT_EC_SANITY_CHECK_FAILED, FNFT__E_SANITY_CHECK_FAILED_(msg)) |
|
#define | FNFT__E_ASSERTION_FAILED FNFT__ERRMSG(FNFT_EC_ASSERTION_FAILED, "Assertion failed.") |
|
#define | FNFT__CHECK_RETCODE(ret_code, label) {if (ret_code!=FNFT_SUCCESS) {ret_code=FNFT__E_SUBROUTINE(ret_code);goto label;}} |
|
#define | FNFT__CHECK_NOMEM(var, ret_code, label) {if (var==NULL) {ret_code=FNFT__E_NOMEM;goto label;}} |
|
#define | FNFT__ERRMSG(ec, msg) fnft__errmsg_aux(ec, __func__, __LINE__, msg); |
|
#define | FNFT__E_INVALID_ARGUMENT_(name) "Invalid argument "#name"." |
|
#define | FNFT__E_NOT_YET_IMPLEMENTED_(name, msg) "Not yet implemented ("#name"). "#msg |
|
#define | FNFT__E_SANITY_CHECK_FAILED_(msg) "Sanity check failed ("#msg")." |
|
This module contains macros that can be used to raise errors and warnings.
Most FNFT functions return one of the error codes defined in the module Error codes. The return type should be FNFT_INT. The error should be risen using the corresponding macro from this group. By using these macros, error messages will be printed. The macro returns the corresponding error code. For example:
if (pointer == NULL)
return FNFT__E_NOMEM;
The function that prints the errors can be changed using fnft_errwarn_setprintf.
◆ FNFT__CHECK_NOMEM
#define FNFT__CHECK_NOMEM |
( |
|
var, |
|
|
|
ret_code, |
|
|
|
label |
|
) |
| {if (var==NULL) {ret_code=FNFT__E_NOMEM;goto label;}} |
Macro for checking if memory has been allocated. If var!=NULL, a FNFT__E_NOMEM error is assigned to ret_code and the macro uses goto to jump to label.
◆ FNFT__CHECK_RETCODE
Macro for checking if a return code indicates an error. If ret_code!=FNFT_SUCCESS, a subroutine error is risen and the macro uses goto to jump to label.
◆ FNFT__E_ASSERTION_FAILED
Macro for raising an assertion check failed error.
◆ FNFT__E_DIV_BY_ZERO
Macro for raising an division by zero error.
◆ FNFT__E_INVALID_ARGUMENT
Macro for raising an invalid argument error.
◆ FNFT__E_INVALID_ARGUMENT_
#define FNFT__E_INVALID_ARGUMENT_ |
( |
|
name | ) |
"Invalid argument "#name"." |
◆ FNFT__E_NOMEM
Macro for raising an out of memory error.
◆ FNFT__E_NOT_YET_IMPLEMENTED
Macro for raising a not yet implemented error, where name is an identifier for the feature and msg is an additional custom error message.
◆ FNFT__E_NOT_YET_IMPLEMENTED_
#define FNFT__E_NOT_YET_IMPLEMENTED_ |
( |
|
name, |
|
|
|
msg |
|
) |
| "Not yet implemented ("#name"). "#msg |
◆ FNFT__E_OTHER
Macro for raising an unspecified error, where msg is a custom error message.
◆ FNFT__E_SANITY_CHECK_FAILED
Macro for raising a sanity check failed error, where msg is a custom error message.
◆ FNFT__E_SANITY_CHECK_FAILED_
#define FNFT__E_SANITY_CHECK_FAILED_ |
( |
|
msg | ) |
"Sanity check failed ("#msg")." |
◆ FNFT__E_SUBROUTINE
#define FNFT__E_SUBROUTINE |
( |
|
ec | ) |
FNFT__ERRMSG(-abs(ec), "Subroutine failure.") |
Macro for raising an subroutine error, where ec is the error code returned by the subroutine. The error code returned by this macro is -abs(ec). Since all other error codes are positive, a negative error code therefore indicates that a subroutine failed with the error code abs(ec).
◆ FNFT__E_TEST_FAILED
Macro for raising a test failed error.
◆ FNFT__ERRMSG
Macro that prints the given error message using fnft__errmsg_aux and returns the error code ec. Auxiliary macro. Do not call directly.
◆ FNFT__WARN
Provides a warning message to the user.
◆ fnft__errmsg_aux()
Auxiliary function that prints a formated error message using the printf function returned by fnft_errwarn_getprintf. It simply returns the error code ec. Do not call directly.
◆ fnft__warn_aux()
void fnft__warn_aux |
( |
const char * |
func, |
|
|
const FNFT_INT |
line, |
|
|
const char * |
msg |
|
) |
| |
Auxiliary function that prints a formated warning message using the printf function returned by fnft_errwarn_getprintf. Do not call directly.