#include "akerror.h" #include "err_capture.h" /* * PASS bubbles an error up to the caller without a local ATTEMPT/PROCESS block: * if the wrapped call fails, PASS returns the context from the current function. * Verify the error reaches main and that the code after PASS is skipped on * failure. */ static int reached_after_pass = 0; akerr_ErrorContext *inner(void) { PREPARE_ERROR(e); FAIL_RETURN(e, AKERR_IO, "inner failed"); } akerr_ErrorContext *outer(void) { PREPARE_ERROR(e); PASS(e, inner()); reached_after_pass = 1; /* must NOT run: PASS returned already */ SUCCEED_RETURN(e); } int main(void) { akerr_capture_install(); int handled = 0; PREPARE_ERROR(e); ATTEMPT { CATCH(e, outer()); } CLEANUP { } PROCESS(e) { } HANDLE(e, AKERR_IO) { AKERR_CHECK_STATUS(e, AKERR_IO); handled = 1; } FINISH_NORETURN(e); AKERR_CHECK(handled == 1); AKERR_CHECK(reached_after_pass == 0); AKERR_CHECK(akerr_slots_in_use() == 0); fprintf(stderr, "err_pass ok\n"); return 0; }