From b6a2f4a840bfb3d7a2861163b09927e61a873d6e Mon Sep 17 00:00:00 2001 From: Fredrik Noring <noring@nocrew.org> Date: Sun, 4 Jun 2000 01:44:01 +0200 Subject: [PATCH] Added experimental convenience exception macros. Rev: src/error.h:1.43 --- src/error.h | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/error.h b/src/error.h index 9639d5e7d7..ae21469bc9 100644 --- a/src/error.h +++ b/src/error.h @@ -5,7 +5,7 @@ \*/ /* - * $Id: error.h,v 1.42 2000/05/25 02:18:35 hubbe Exp $ + * $Id: error.h,v 1.43 2000/06/03 23:44:01 noring Exp $ */ #ifndef ERROR_H #define ERROR_H @@ -255,3 +255,41 @@ void cleanup_error(void); #ifndef PIKE_DEBUG #define check_recovery_context() ((void)0) #endif + +/* Experimental convenience exception macros. */ + +#define exception_try \ + do \ + { \ + int __exception_rethrow, __is_exception; \ + JMP_BUF exception; \ + __is_exception = SETJMP(exception); \ + __exception_rethrow = 0; \ + if(__is_exception) /* rethrow needs this */ \ + UNSETJMP(exception); \ + if(!__is_exception) + +#define exception_catch_if \ + else if + +#define exception_catch(e) \ + exception_catch_if(exception->severity = (e)) + +#define exception_catch_all \ + exception_catch_if(1) + +#define exception_semicatch_all \ + exception_catch_if((__exception_rethrow = 1)) + +#define rethrow \ + pike_throw() + +#define exception_endtry \ + else \ + __exception_rethrow = 1; \ + if(!__is_exception) \ + UNSETJMP(exception); \ + if(__exception_rethrow) \ + rethrow; \ + } \ + while(0) -- GitLab