43 lines
837 B
C
43 lines
837 B
C
#include "akerror.h"
|
|
|
|
int x;
|
|
|
|
akerr_ErrorContext *func2(void)
|
|
{
|
|
PREPARE_ERROR(errctx);
|
|
ATTEMPT {
|
|
FAIL(errctx, AKERR_NULLPOINTER, "This is a failure in func2");
|
|
} CLEANUP {
|
|
} PROCESS(errctx) {
|
|
} FINISH(errctx, true);
|
|
SUCCEED_RETURN(errctx);
|
|
}
|
|
|
|
akerr_ErrorContext *func1(void)
|
|
{
|
|
PREPARE_ERROR(errctx);
|
|
ATTEMPT {
|
|
CATCH(errctx, func2());
|
|
} CLEANUP {
|
|
x = 0;
|
|
} PROCESS(errctx) {
|
|
} FINISH(errctx, true);
|
|
SUCCEED_RETURN(errctx);
|
|
}
|
|
|
|
akerr_ErrorContext *akerr_user_main(int argc, char **argv)
|
|
{
|
|
x = 12345;
|
|
PREPARE_ERROR(errctx);
|
|
ATTEMPT {
|
|
CATCH(errctx, func1());
|
|
} CLEANUP {
|
|
} PROCESS(errctx) {
|
|
} HANDLE(errctx, AKERR_NULLPOINTER) {
|
|
if ( x == 0 ) {
|
|
FAIL_RETURN(errctx, AKERR_API, "Cleanup does not work");
|
|
}
|
|
} FINISH(errctx, true);
|
|
SUCCEED(errctx);
|
|
}
|