Skip to content

Commit 7c9f57e

Browse files
committed
Fixed the issue with System.Reflection.TargetInvocationExeption bubbling all the way up to the hosting environment
1 parent 51c4bfe commit 7c9f57e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Src/IronJS/Hosting.fs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,14 @@ module FSharp =
148148

149149
///
150150
let internal run (compiled:Delegate) (t:T) =
151-
compiled.DynamicInvoke(t.GlobalFunc, t |> globals)
151+
try
152+
compiled.DynamicInvoke(t.GlobalFunc, t |> globals)
153+
154+
with
155+
| :? System.Reflection.TargetInvocationException as exn ->
156+
if exn.GetBaseException() :? UserError
157+
then raise <| exn.GetBaseException()
158+
else raise exn
152159

153160
///
154161
let internal compile source (t:T) =

0 commit comments

Comments
 (0)