Files
libakerror/tests/err_catch.c

37 lines
702 B
C
Raw Permalink Normal View History

#include "akerror.h"
2025-07-21 07:19:41 -04:00
akerr_ErrorContext *func2(void)
2025-07-21 07:19:41 -04:00
{
PREPARE_ERROR(errctx);
ATTEMPT {
FAIL(errctx, AKERR_NULLPOINTER, "This is a failure in func2");
2025-07-21 07:19:41 -04:00
} CLEANUP {
} PROCESS(errctx) {
} FINISH(errctx, true);
SUCCEED_RETURN(errctx);
}
akerr_ErrorContext *func1(void)
2025-07-21 07:19:41 -04:00
{
PREPARE_ERROR(errctx);
ATTEMPT {
CATCH(errctx, func2());
} CLEANUP {
} PROCESS(errctx) {
} FINISH(errctx, true);
SUCCEED_RETURN(errctx);
}
int main(void)
{
PREPARE_ERROR(errctx);
ATTEMPT {
CATCH(errctx, func1());
} CLEANUP {
} PROCESS(errctx) {
} HANDLE(errctx, AKERR_NULLPOINTER) {
akerr_log_method("Caught exception");
2025-07-21 07:19:41 -04:00
} FINISH_NORETURN(errctx);
}