XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEExtension.NetCore.ServerInteractive

[DLL] Server interaction extension, including user identity verification and querying in conjunction with AutoConfig

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/XFEExtension.NetCore.ServerInteractive

调整部分类型名称 优化输出显示

afbbb10
XFE工作室室长 <mail@xfegzs.com>
提交于

代码差异

5 个文件 +49 -16
Modified XFEExtension.NetCore.ServerInteractive/Utilities/DataTable/XFEDataDictionaryTable.cs +1 -1
@@ -206,7 +206,7 @@ public class XFEDataDictionaryTable<TValue> : IXFEDataTable where TValue : IIdMo
206 206 }
207 207 catch (Exception ex)
208 208 {
209 Console.WriteLine($"[WARN]({r.ServerCore.ServerCoreName}){ex.Message}");
209 Console.WriteLine($"[WARN]({r.ServerCore.ServerCoreName}){ExceptionHelper.GetExceptionMessage(ex)}");
210 210 Console.WriteLine($"[TRACE]{ex.StackTrace}");
211 211 await r.Args.ReplyAndClose(ex.Message, statusCode);
212 212 }
Modified XFEExtension.NetCore.ServerInteractive/Utilities/DataTable/XFEDataListTable.cs +1 -1
@@ -215,7 +215,7 @@ public class XFEDataListTable<T> : IXFEDataTable where T : IIdModel
215 215 }
216 216 catch (Exception ex)
217 217 {
218 Console.WriteLine($"[WARN]({r.ServerCore.ServerCoreName}){ex.Message}");
218 Console.WriteLine($"[WARN]({r.ServerCore.ServerCoreName}){ExceptionHelper.GetExceptionMessage(ex)}");
219 219 Console.WriteLine($"[TRACE]{ex.StackTrace}");
220 220 await r.Args.ReplyAndClose(ex.Message, statusCode);
221 221 }
Added XFEExtension.NetCore.ServerInteractive/Utilities/Helpers/ExceptionHelper.cs +36 -0
@@ -0,0 +1,36 @@
1 namespace XFEExtension.NetCore.ServerInteractive.Utilities.Helpers;
2
3 /// <summary>
4 /// 异常帮助类
5 /// </summary>
6 public static class ExceptionHelper
7 {
8 /// <summary>
9 /// 获取异常消息及其内部异常消息
10 /// </summary>
11 /// <param name="exception">异常</param>
12 /// <param name="maxInnerExceptionDepth">最大内部异常层数</param>
13 /// <returns>异常消息</returns>
14 public static string GetExceptionMessage(Exception? exception, int maxInnerExceptionDepth = 5)
15 {
16 if (exception is null)
17 {
18 return string.Empty;
19 }
20
21 var errorMessage = exception.Message;
22 var currentException = exception.InnerException;
23 for (var i = 0; i < maxInnerExceptionDepth; i++)
24 {
25 if (currentException is null)
26 {
27 break;
28 }
29
30 errorMessage += $":{currentException.Message}";
31 currentException = currentException.InnerException;
32 }
33
34 return errorMessage;
35 }
36 }
Modified XFEExtension.NetCore.ServerInteractive/Utilities/Server/Services/CoreService/ServerCoreExceptionProcessService.cs +8 -12
@@ -1,6 +1,7 @@
1 using XFEExtension.NetCore.CyberComm;
1 using XFEExtension.NetCore.CyberComm;
2 2 using XFEExtension.NetCore.ServerInteractive.Implements.CoreService;
3 3 using XFEExtension.NetCore.ServerInteractive.Models.ServerModels;
4 using XFEExtension.NetCore.ServerInteractive.Utilities.Helpers;
4 5
5 6 namespace XFEExtension.NetCore.ServerInteractive.Utilities.Server.Services.CoreService;
6 7
@@ -24,8 +25,12 @@ public class ServerCoreExceptionProcessService : ServerCoreOriginalServiceBase
24 25 try
25 26 {
26 27 if (e.Handled || e.ReturnArgs is null) return;
27 var currentException = e.ServerException?.InnerException;
28 var errorMessage = e.ServerException?.Message ?? "服务器内部异常";
28 var errorMessage = ExceptionHelper.GetExceptionMessage(e.ServerException);
29 if (string.IsNullOrEmpty(errorMessage))
30 {
31 errorMessage = "服务器内部异常";
32 }
33
29 34 var errorInfo = string.Empty;
30 35 if (e.ServerException?.InnerException is ServerCoreReturnArgs returnArgs)
31 36 errorInfo = returnArgs.ReturnMessage;
@@ -35,15 +40,6 @@ public class ServerCoreExceptionProcessService : ServerCoreOriginalServiceBase
35 40 }
36 41 else
37 42 {
38 for (var i = 0; i < 5; i++)
39 {
40 if (currentException is null)
41 {
42 break;
43 }
44 errorMessage += $":{currentException.Message}";
45 currentException = currentException.InnerException;
46 }
47 43 errorInfo = errorMessage.Contains("请求的路由未注册") ? "路由未找到" : "服务器内部异常";
48 44 Console.WriteLine();
49 45 Console.WriteLine($"[WARN]({sender.ServerCoreName})【{errorInfo}】{errorMessage}");
Modified XFEExtension.NetCore.ServerInteractive/XFEExtension.NetCore.ServerInteractive.csproj +3 -2
@@ -5,7 +5,7 @@
5 5 <ImplicitUsings>enable</ImplicitUsings>
6 6 <Nullable>enable</Nullable>
7 7 <GenerateDocumentationFile>True</GenerateDocumentationFile>
8 <Version>3.1.0-preview.1.1</Version>
8 <Version>3.1.0-preview.1.2</Version>
9 9 <Title>XFEExtension.NetCore.ServerInteractive</Title>
10 10 <RepositoryUrl>https://github.com/XFEstudio/XFEExtension.NetCore.ServerInteractive</RepositoryUrl>
11 11 <AnalysisLevel>latest</AnalysisLevel>
@@ -21,7 +21,8 @@
21 21 <PackageReleaseNotes>
22 22 ## 调整
23 23
24 更新md文档
24 调整部分类型名称
25 优化输出显示
25 26
26 27 ## 新增
27 28