#include "akerror.h" #include "err_capture.h" /* * The success path: a nested call that returns cleanly (NULL) must not break * out of the caller's ATTEMPT block, must not enter any handler, and must not * consume a slot from the error pool. */ static int default_fired = 0; akerr_ErrorContext *ok_func(void) { PREPARE_ERROR(e); ATTEMPT { } CLEANUP { } PROCESS(e) { } FINISH(e, true); SUCCEED_RETURN(e); } int main(void) { akerr_capture_install(); akerr_init(); int reached_after_catch = 0; PREPARE_ERROR(e); ATTEMPT { CATCH(e, ok_func()); reached_after_catch = 1; /* must run: no break on success */ } CLEANUP { } PROCESS(e) { } HANDLE_DEFAULT(e) { default_fired = 1; /* must NOT run */ } FINISH_NORETURN(e); AKERR_CHECK(reached_after_catch == 1); AKERR_CHECK(default_fired == 0); AKERR_CHECK(e == NULL); AKERR_CHECK(akerr_slots_in_use() == 0); fprintf(stderr, "err_success ok\n"); return 0; }