How to handle recoverable errors using bj_error.
How to handle recoverable errors using bj_error.
#include <banjo/main.h>
#define CODE 101
void function_returning_error(
bj_error** error) {
}
void function_calling_failing_function(
bj_error** error) {
function_returning_error(&sub_err);
if(sub_err != 0) {
return;
}
bj_info(
"This should not be printed\n");
}
int main(int argc, char* argv[]) {
(void)argc;
(void)argv;
function_returning_error(0);
function_returning_error(&error);
if(error != 0) {
}
bj_info(
"Error domain and code match");
}
function_calling_failing_function(&error);
bj_info(
"Error from nested function");
}
return 0;
}
Recoverable error handling.
void bj_set_error(bj_error **p_error, uint32_t code, const char *message)
Fills in a bj_error object with given code and message.
void bj_clear_error(bj_error **p_error)
Clears the given error location.
bj_bool bj_forward_error(bj_error *p_source, bj_error **p_destination)
Forward an error into another error location.
bj_bool bj_error_check(const bj_error *p_error, uint32_t code)
Checks if the given error matches the error code.
Error structure.
Definition error.h:131
#define bj_info(...)
Log a message using the BJ_LOG_INFO level.
Definition log.h:103
Logging utility functions.