From 46bc612f5754e7eca8a232a9e9ae7cfde0cee5e0 Mon Sep 17 00:00:00 2001 From: walon Date: Wed, 4 Aug 2021 10:05:14 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91=E4=BC=98?= =?UTF-8?q?=E5=8C=96cfg=E6=97=A5=E5=BF=97=EF=BC=8C=E4=B8=8D=E5=86=8D?= =?UTF-8?q?=E6=89=93=E5=8D=B0=E5=90=93=E4=BA=BA=E7=9A=84=E5=A0=86=E6=A0=88?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 ++- .../Source/DataSources/DataSourceFactory.cs | 2 +- .../DataSources/Excel/ExcelDataSource.cs | 6 ++--- src/Luban.Job.Cfg/Source/Defs/CfgDefLoader.cs | 2 +- src/Luban.Job.Cfg/Source/JobController.cs | 9 +++++++- .../Source/Utils/DataLoaderUtil.cs | 4 ++-- .../Source/Utils/ExceptionUtil.cs | 23 +++++++++++++++++++ src/Luban.Job.Proto/Source/JobController.cs | 3 ++- 8 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 src/Luban.Job.Common/Source/Utils/ExceptionUtil.cs diff --git a/README.md b/README.md index 9299b58..af6b725 100644 --- a/README.md +++ b/README.md @@ -44,10 +44,11 @@ Luban适合有以下需求的开发者: - **====>强烈推荐查看:示例项目** ([github](https://github.com/focus-creative-games/luban_examples)) ([gitee](https://gitee.com/focus-creative-games/luban_examples)) **<====** - 支持与联系 - - QQ群: 692890842 (Luban开发交流群)。有使用方面的疑问请及时加QQ群询问,随时有人帮助解决。 + - QQ群: 692890842 (Luban开发交流群) [点击链接加入](https://qm.qq.com/cgi-bin/qm/qr?k=4bMoe11knBW7Tcs1sqMafZE1I4zpT4sh&jump_from=webapi)。 有使用方面的疑问请及时加QQ群询问,随时有人帮助解决。 - 邮箱: taojingjian#gmail.com - Skypy群: https://join.skype.com/xr2nhdMKjac0 + ## 特性 - 支持增强的excel格式,可以在excel里比较简洁填写出任意复杂的数据 - 支持excel族、json、xml、lua 多种数据格式,基本统一了游戏内的配置数据 diff --git a/src/Luban.Job.Cfg/Source/DataSources/DataSourceFactory.cs b/src/Luban.Job.Cfg/Source/DataSources/DataSourceFactory.cs index 1783fc7..b1c5193 100644 --- a/src/Luban.Job.Cfg/Source/DataSources/DataSourceFactory.cs +++ b/src/Luban.Job.Cfg/Source/DataSources/DataSourceFactory.cs @@ -32,7 +32,7 @@ namespace Luban.Job.Cfg.DataSources } catch (Exception e) { - throw new Exception($"文件{url} 加载失败 ==> {e.Message}", e); + throw new Exception($"文件{url} 加载失败", e); } } } diff --git a/src/Luban.Job.Cfg/Source/DataSources/Excel/ExcelDataSource.cs b/src/Luban.Job.Cfg/Source/DataSources/Excel/ExcelDataSource.cs index 5e69ef1..8d74065 100644 --- a/src/Luban.Job.Cfg/Source/DataSources/Excel/ExcelDataSource.cs +++ b/src/Luban.Job.Cfg/Source/DataSources/Excel/ExcelDataSource.cs @@ -40,7 +40,7 @@ namespace Luban.Job.Cfg.DataSources.Excel } catch (Exception e) { - throw new Exception($"excel:{rawUrl} sheet:{reader.Name} 读取失败. ==> {e.Message}", e); + throw new Exception($"excel:{rawUrl} sheet:{reader.Name} 读取失败.", e); } } @@ -73,7 +73,7 @@ namespace Luban.Job.Cfg.DataSources.Excel } catch (Exception e) { - throw new Exception($"excel:{rawUrl} sheet:{reader.Name} 读取失败. ==> {e.Message}", e); + throw new Exception($"excel:{rawUrl} sheet:{reader.Name} 读取失败.", e); } } @@ -110,7 +110,7 @@ namespace Luban.Job.Cfg.DataSources.Excel } catch (Exception e) { - throw new Exception($"sheet:{sheet.Name} ==> {e.Message} {e.StackTrace}", e); + throw new Exception($"sheet:{sheet.Name}", e); } } return datas; diff --git a/src/Luban.Job.Cfg/Source/Defs/CfgDefLoader.cs b/src/Luban.Job.Cfg/Source/Defs/CfgDefLoader.cs index c79246b..9bee077 100644 --- a/src/Luban.Job.Cfg/Source/Defs/CfgDefLoader.cs +++ b/src/Luban.Job.Cfg/Source/Defs/CfgDefLoader.cs @@ -529,7 +529,7 @@ namespace Luban.Job.Cfg.Defs FillValueValidator(f, e.Attribute("ref"), "ref"); - FillValueValidator(f, e.Attribute("path"), "path"); // (ue4|normal|regex);xxx;xxx + FillValueValidator(f, e.Attribute("path"), "path"); // (ue4|unity|normal|regex);xxx;xxx FillValueValidator(f, e.Attribute("range"), "range"); FillValidators(e, "key_validator", f.KeyValidators); diff --git a/src/Luban.Job.Cfg/Source/JobController.cs b/src/Luban.Job.Cfg/Source/JobController.cs index 4aae87b..a3fdb8f 100644 --- a/src/Luban.Job.Cfg/Source/JobController.cs +++ b/src/Luban.Job.Cfg/Source/JobController.cs @@ -454,7 +454,14 @@ namespace Luban.Job.Cfg catch (Exception e) { res.ErrCode = Luban.Common.EErrorCode.JOB_EXCEPTION; - res.ErrMsg = $"{e.Message} \n {e.StackTrace}"; + res.ErrMsg = $@" +======================================================================= + +{ExceptionUtil.ExtractMessage(e)} + +======================================================================= +"; + res.StackTrace = e.StackTrace; } DefAssemblyBase.LocalAssebmly = null; timer.EndPhaseAndLog(); diff --git a/src/Luban.Job.Cfg/Source/Utils/DataLoaderUtil.cs b/src/Luban.Job.Cfg/Source/Utils/DataLoaderUtil.cs index 8afc34c..a39f034 100644 --- a/src/Luban.Job.Cfg/Source/Utils/DataLoaderUtil.cs +++ b/src/Luban.Job.Cfg/Source/Utils/DataLoaderUtil.cs @@ -197,7 +197,7 @@ namespace Luban.Job.Cfg.Utils } catch (Exception e) { - throw new Exception($"配置文件:{originFile} 生成失败. ==> {e.Message}", e); + throw new Exception($"配置文件:{originFile} 生成失败.", e); } } @@ -220,7 +220,7 @@ namespace Luban.Job.Cfg.Utils } catch (Exception e) { - throw new Exception($"load text table file:{files[i]} fail. ==> {e.Message} "); + throw new Exception($"load text table file:{files[i]} fail", e); } } } diff --git a/src/Luban.Job.Common/Source/Utils/ExceptionUtil.cs b/src/Luban.Job.Common/Source/Utils/ExceptionUtil.cs new file mode 100644 index 0000000..0dc2e92 --- /dev/null +++ b/src/Luban.Job.Common/Source/Utils/ExceptionUtil.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Luban.Job.Common.Utils +{ + public static class ExceptionUtil + { + public static string ExtractMessage(Exception e) + { + var lines = new List(); + do + { + lines.Add("===> " + e.Message); + e = e.InnerException; + } while (e != null); + + return string.Join('\n', lines); + } + } +} diff --git a/src/Luban.Job.Proto/Source/JobController.cs b/src/Luban.Job.Proto/Source/JobController.cs index 36e6e9b..88b65c3 100644 --- a/src/Luban.Job.Proto/Source/JobController.cs +++ b/src/Luban.Job.Proto/Source/JobController.cs @@ -215,7 +215,8 @@ namespace Luban.Job.Proto catch (Exception e) { res.ErrCode = Luban.Common.EErrorCode.JOB_EXCEPTION; - res.ErrMsg = $"{e.Message} \n {e.StackTrace}"; + res.ErrMsg = ExceptionUtil.ExtractMessage(e); + res.StackTrace = e.StackTrace; } DefAssemblyBase.LocalAssebmly = null;