Browse Source

Let exceptions bubble from ReflectionAccessor (#1023)

Marko Lahma 3 years ago
parent
commit
b40718fcc7

+ 13 - 0
Jint.Tests/Runtime/InteropTests.cs

@@ -2733,5 +2733,18 @@ namespace Jint.Tests.Runtime
             var ex = Assert.Throws<JavaScriptException>(() => engine.Execute("a.age = \"It won't work, but it's normal\""));
             Assert.Equal("Input string was not in a correct format.", ex.Message);
         }
+
+        [Fact]
+        public void ShouldLetNotSupportedExceptionBubble()
+        {
+            _engine.SetValue("profile", new Profile());
+            var ex = Assert.Throws<NotSupportedException>(() => _engine.Evaluate("profile.AnyProperty"));
+            Assert.Equal("NOT SUPPORTED", ex.Message);
+        }
+
+        private class Profile
+        {
+            public int AnyProperty => throw new NotSupportedException("NOT SUPPORTED");
+        }
     }
 }

+ 0 - 9
Jint/Runtime/Interop/Reflection/ReflectionAccessor.cs

@@ -52,15 +52,6 @@ namespace Jint.Runtime.Interop.Reflection
                 }
                 catch (TargetInvocationException tie)
                 {
-                    switch (tie.InnerException)
-                    {
-                        case ArgumentOutOfRangeException _:
-                        case IndexOutOfRangeException _:
-                        case InvalidOperationException _:
-                        case NotSupportedException _:
-                            return JsValue.Undefined;
-                    }
-
                     ExceptionHelper.ThrowMeaningfulException(engine, tie);
                 }
             }