From 3d6adccfbec44fb13a75ef7055f10fb87242d1fc Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 29 Sep 2020 10:21:10 +0900 Subject: Add a new function `mrb_exc_protect()`. `mrb_exc_protect()` takes two C functions, `body` to be executed first, and `resc` to be executed when an error happens during `body` execution. Since `mrb_exc_protect()` should be compiled with the proper compiler, we will not see the problem like #5088 that was caused by `setjmp()` and `throw` mixture. --- include/mruby.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/mruby.h b/include/mruby.h index 52bcd58bf..4bbffb189 100644 --- a/include/mruby.h +++ b/include/mruby.h @@ -1293,6 +1293,9 @@ MRB_API void mrb_print_backtrace(mrb_state *mrb); MRB_API void mrb_print_error(mrb_state *mrb); /* function for `raisef` formatting */ MRB_API mrb_value mrb_vformat(mrb_state *mrb, const char *format, va_list ap); +/* function to protect errors during execution */ +MRB_API mrb_value mrb_exc_protect(mrb_state *mrb, mrb_value (*body)(mrb_state*, void*), void *a, mrb_value (*resc)(mrb_state*, void*, mrb_value), void *b); + /* macros to get typical exception objects note: -- cgit v1.2.3