From 8d6d6e45afa02539ca2a26027087a31dbabc6e00 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Fri, 23 Nov 2018 13:34:21 +0100 Subject: [PATCH] Handle lua -> C# function invocation exceptions more gracefully --- Upsilon/BaseTypes/LuaFunction.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Upsilon/BaseTypes/LuaFunction.cs b/Upsilon/BaseTypes/LuaFunction.cs index f5caff8..771c9da 100644 --- a/Upsilon/BaseTypes/LuaFunction.cs +++ b/Upsilon/BaseTypes/LuaFunction.cs @@ -75,7 +75,16 @@ namespace Upsilon.BaseTypes objects.Add(null); } } - return method.Invoke(_object, objects.ToArray()).ToLuaType(); + + try + { + return method.Invoke(_object, objects.ToArray()).ToLuaType(); + } + catch (TargetInvocationException e) + { + if (e.InnerException != null) throw e.InnerException; + throw; + } } } } \ No newline at end of file