Commit f15f63ae authored by Erik Nilsen Haga's avatar Erik Nilsen Haga Committed by Vinicius Jarina
Browse files

Wrap invokation in try catch.

parent 8498b6fb
...@@ -1301,14 +1301,27 @@ namespace NLua ...@@ -1301,14 +1301,27 @@ namespace NLua
if (isOk) if (isOk)
{ {
object result; object result;
try
{
if (methodDelegate.IsStatic)
result = methodDelegate.Invoke(null, validDelegate.args);
else
result = methodDelegate.Invoke(del.Target, validDelegate.args);
if (methodDelegate.IsStatic) _translator.Push(luaState, result);
result = methodDelegate.Invoke(null, validDelegate.args); return 1;
else }
result = methodDelegate.Invoke(del.Target, validDelegate.args); catch (TargetInvocationException e)
{
_translator.Push(luaState, result); // Failure of method invocation
return 1; if (_translator.interpreter.UseTraceback)
e.GetBaseException().Data["Traceback"] = _translator.interpreter.GetDebugTraceback();
return _translator.Interpreter.SetPendingException(e.GetBaseException());
}
catch (Exception e)
{
return _translator.Interpreter.SetPendingException(e);
}
} }
_translator.ThrowError(luaState, "Cannot invoke delegate (invalid arguments for " + methodDelegate.Name + ")"); _translator.ThrowError(luaState, "Cannot invoke delegate (invalid arguments for " + methodDelegate.Name + ")");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment