- Added explicit status validation across error handling tests. - Added lifecycle and slot-leak checks to older tests. - Improved unhandled-error propagation coverage. - Added repository guidance and a test runner script. - Verified all 23 CTest tests pass. Co-Authored by Codex GPT 5.4
46 lines
962 B
C
46 lines
962 B
C
#include "akerror.h"
|
|
#include "err_capture.h"
|
|
|
|
/*
|
|
* With several distinct HANDLE blocks, only the one matching the raised status
|
|
* may run. Raise the middle code and confirm exact dispatch.
|
|
*/
|
|
|
|
static int a_fired = 0;
|
|
static int b_fired = 0;
|
|
static int c_fired = 0;
|
|
static int b_status = 0;
|
|
|
|
akerr_ErrorContext *boom(void)
|
|
{
|
|
PREPARE_ERROR(e);
|
|
FAIL_RETURN(e, AKERR_TYPE, "the middle one");
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
akerr_capture_install();
|
|
|
|
PREPARE_ERROR(e);
|
|
ATTEMPT {
|
|
CATCH(e, boom());
|
|
} CLEANUP {
|
|
} PROCESS(e) {
|
|
} HANDLE(e, AKERR_KEY) {
|
|
a_fired = 1;
|
|
} HANDLE(e, AKERR_TYPE) {
|
|
b_fired = 1;
|
|
b_status = e->status;
|
|
} HANDLE(e, AKERR_IO) {
|
|
c_fired = 1;
|
|
} FINISH_NORETURN(e);
|
|
|
|
AKERR_CHECK(a_fired == 0);
|
|
AKERR_CHECK(b_fired == 1);
|
|
AKERR_CHECK(b_status == AKERR_TYPE);
|
|
AKERR_CHECK(c_fired == 0);
|
|
AKERR_CHECK(akerr_slots_in_use() == 0);
|
|
fprintf(stderr, "err_handle_dispatch ok\n");
|
|
return 0;
|
|
}
|