#include "akerror.h" #include "err_capture.h" /* * An error whose status has no matching HANDLE block must fall through to * HANDLE_DEFAULT, and the non-matching HANDLE body must not run. */ static int specific_fired = 0; static int default_fired = 0; static int default_status = 0; akerr_ErrorContext *boom(void) { PREPARE_ERROR(e); FAIL_RETURN(e, AKERR_TYPE, "wrong type"); } int main(void) { akerr_capture_install(); PREPARE_ERROR(e); ATTEMPT { CATCH(e, boom()); } CLEANUP { } PROCESS(e) { } HANDLE(e, AKERR_KEY) { specific_fired = 1; /* must NOT run: error is AKERR_TYPE */ } HANDLE_DEFAULT(e) { default_fired = 1; default_status = e->status; } FINISH_NORETURN(e); AKERR_CHECK(specific_fired == 0); AKERR_CHECK(default_fired == 1); AKERR_CHECK(default_status == AKERR_TYPE); AKERR_CHECK(akerr_slots_in_use() == 0); fprintf(stderr, "err_handle_default ok\n"); return 0; }