using System; using System.Linq; using System.Text; namespace Core.Util { ///
<summary> /// 异常处理帮助类 /// </summary> public static class ExceptionHelper { ///
<summary> /// 获取异常位置 /// </summary> /// <param name="e">异常</param> ///
<returns></returns> private static string GetExceptionAddr(Exception e) {
StringBuilder excAddrBuilder = new StringBuilder(); e?.StackTrace?.Split("\r\n".
ToArray())?.ToList()?.ForEach(item => { if (item.Contains("行号") || item.Contains
("line")) excAddrBuilder.Append($" {item}\r\n"); }); string addr =
excAddrBuilder.ToString(); return addr.IsNullOrEmpty() ? " 无" : addr; } ///
<summary> /// 获取异常消息 /// </summary> /// <param name="ex">捕捉的异常</param> ///
<param name="level">内部异常层级</param> /// <returns></returns> private static string
GetExceptionAllMsg(Exception ex, int level) { StringBuilder builder = new
StringBuilder(); builder.Append($
@"{level}层错误:消息:{ex?.Message}位置:{GetExceptionAddr(ex)}"); if (ex.InnerException
!= null) { builder.Append(GetExceptionAllMsg(ex.InnerException, level + 1)); }
return builder.ToString(); } /// <summary> /// 获取异常消息 /// </summary> /// <param
name="ex">捕捉的异常</param> /// <returns></returns> public static string
GetExceptionAllMsg(Exception ex) { string msg = GetExceptionAllMsg(ex, 1);
return msg; } } }

技术
©2019-2020 Toolsou All rights reserved,
ajax get请求中文参数乱码解决继承jpa Repository 写自定义方法查询判断当前对象是不是数组的4种方式pytorch之ResNet18(对cifar10数据进行分类准确度达到94%)Centos7 下mysql8.0的安装以及修改初始密码;Vue页面跳转传递参数及接收python 动态规划求解单源最短路径element-ui的el-date-picker组件获取值华为鸿蒙操作系统有哪些特点和优势?余承东《全场景时代 新体验与新生态》演讲全文 项目跟了一年,客户最后说不做了