From bcee19028e4ce0b6e752a064a3c7e94a8c73a390 Mon Sep 17 00:00:00 2001 From: Stephanie Gawroriski Date: Sat, 9 Dec 2023 01:29:19 +0000 Subject: [PATCH] Add base for nested exceptions. --- nanocoat/include/sjme/except.h | 8 +++++++- nanocoat/tests/testExceptFail.c | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/nanocoat/include/sjme/except.h b/nanocoat/include/sjme/except.h index 6839b3baac..01b4c106fb 100644 --- a/nanocoat/include/sjme/except.h +++ b/nanocoat/include/sjme/except.h @@ -75,13 +75,19 @@ struct sjme_exceptTrace setjmp((*((jmp_buf*)(&exceptTrace_sjme.jumpBuf)))); \ } while(SJME_JNI_FALSE); \ if (exceptTraceE_sjme != 0) \ - {goto sjme_except_fail; goto sjme_except_with;} \ + {goto sjme_except_fail; goto sjme_except_with; goto sjme_except_done;} \ sjme_except_with /** Exception handling with a Java frame. */ #define SJME_EXCEPT_WITH_FRAME \ SJME_EXCEPT_WITH(frame->inThread->except) +/** Block to declare that exception handling is done and no more. */ +#define SJME_EXCEPT_DONE \ + do { \ + } while(SJME_JNI_FALSE); \ + sjme_except_done + /** Block to declare failing code, for cleanup and return. */ #define SJME_EXCEPT_FAIL \ sjme_except_fail: \ diff --git a/nanocoat/tests/testExceptFail.c b/nanocoat/tests/testExceptFail.c index 8a677fba30..a83c21f0a5 100644 --- a/nanocoat/tests/testExceptFail.c +++ b/nanocoat/tests/testExceptFail.c @@ -38,7 +38,8 @@ SJME_EXCEPT_WITH(trace): SJME_EXCEPT_FAIL: sjme_unitEqualI(test, exceptTraceE_sjme, SJME_ERROR_TOP_NOT_LONG, "Error code was not set?"); - + +SJME_EXCEPT_DONE: /* Success otherwise. */ return SJME_TEST_RESULT_PASS; } -- 2.11.4.GIT