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() {