diff --git a/Engine/Controllers/LCFunctionController.cs b/Engine/Controllers/LCFunctionController.cs index dec02b2..00f84a2 100644 --- a/Engine/Controllers/LCFunctionController.cs +++ b/Engine/Controllers/LCFunctionController.cs @@ -47,8 +47,8 @@ namespace LeanCloud.Engine { object result = await LCEngine.Invoke(mi, req); if (result != null) { return new Dictionary { - { "result", result } - }; + { "result", result } + }; } } return default; diff --git a/Engine/LCEngine.cs b/Engine/LCEngine.cs index f29b83d..595a777 100644 --- a/Engine/LCEngine.cs +++ b/Engine/LCEngine.cs @@ -213,7 +213,14 @@ namespace LeanCloud.Engine { } return mi.Invoke(null, ps); } catch (TargetInvocationException e) { - throw e.InnerException; + Exception ex = e.InnerException; + if (ex is LCException lcEx) { + throw new Exception(JsonConvert.SerializeObject(new Dictionary { + { "code", lcEx.Code }, + { "message", lcEx.Message } + })); + } + throw ex; } }