From 269fef478883890e15205f5f7e5295921567f40a Mon Sep 17 00:00:00 2001 From: Rudy Ges Date: Thu, 28 Sep 2023 15:44:57 +0200 Subject: [PATCH] [eval,hl] fix catching value exceptions Closes #11321 --- src/filters/exceptions.ml | 2 +- tests/unit/src/unit/TestExceptions.hx | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/filters/exceptions.ml b/src/filters/exceptions.ml index d092e890d7d..a9c97dfdea7 100644 --- a/src/filters/exceptions.ml +++ b/src/filters/exceptions.ml @@ -484,7 +484,7 @@ let catch_native ctx catches t p = | [], None -> catches_to_ifs ctx catches t p | [], Some catch -> - catches_to_ifs ctx [catch] t p + catches_to_ifs ctx (catch :: catches) t p | _ -> catches_as_value_exception ctx handle_as_value_exception None t p :: catches_to_ifs ctx catches t p diff --git a/tests/unit/src/unit/TestExceptions.hx b/tests/unit/src/unit/TestExceptions.hx index 6fb5580af80..0d00ca01558 100644 --- a/tests/unit/src/unit/TestExceptions.hx +++ b/tests/unit/src/unit/TestExceptions.hx @@ -162,6 +162,14 @@ class TestExceptions extends Test { } catch(e:String) { eq('string', e); } + + try { + throw new CustomHaxeException('Terrible error'); + } catch(e:haxe.ValueException) { + throw 'should not happen'; + } catch(e) { + Assert.pass(); + } } public function testCustomNativeException() {