From 4bb16ce4233afa75dd3ddd3ac00db5d1e824cea1 Mon Sep 17 00:00:00 2001 From: oneRain Date: Mon, 22 Mar 2021 17:06:12 +0800 Subject: [PATCH] chore: LCException --- Engine/Controllers/LCFunctionController.cs | 4 ++-- Engine/LCEngine.cs | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) 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; } }