2026-07-27 16:18:17 -04:00
|
|
|
#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;
|
2026-07-29 17:09:45 -04:00
|
|
|
static int default_status = 0;
|
2026-07-27 16:18:17 -04:00
|
|
|
|
|
|
|
|
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;
|
2026-07-29 17:09:45 -04:00
|
|
|
default_status = e->status;
|
2026-07-27 16:18:17 -04:00
|
|
|
} FINISH_NORETURN(e);
|
|
|
|
|
|
|
|
|
|
AKERR_CHECK(specific_fired == 0);
|
|
|
|
|
AKERR_CHECK(default_fired == 1);
|
2026-07-29 17:09:45 -04:00
|
|
|
AKERR_CHECK(default_status == AKERR_TYPE);
|
2026-07-27 16:18:17 -04:00
|
|
|
AKERR_CHECK(akerr_slots_in_use() == 0);
|
|
|
|
|
fprintf(stderr, "err_handle_default ok\n");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|