using System; using System.Linq; using System.Text; namespace Core.Util { ///
<summary> /// Exception handling help class /// </summary> public static class ExceptionHelper { ///
<summary> /// Get exception location /// </summary> /// <param name="e"> abnormal </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(" Line number ") || item.Contains
("line")) excAddrBuilder.Append($" {item}\r\n"); }); string addr =
excAddrBuilder.ToString(); return addr.IsNullOrEmpty() ? " nothing " : addr; } ///
<summary> /// Get exception message /// </summary> /// <param name="ex"> Exception caught </param> ///
<param name="level"> Internal exception level </param> /// <returns></returns> private static string
GetExceptionAllMsg(Exception ex, int level) { StringBuilder builder = new
StringBuilder(); builder.Append($
@"{level} Layer error : news :{ex?.Message} position :{GetExceptionAddr(ex)}"); if (ex.InnerException
!= null) { builder.Append(GetExceptionAllMsg(ex.InnerException, level + 1)); }
return builder.ToString(); } /// <summary> /// Get exception message /// </summary> /// <param
name="ex"> Exception caught </param> /// <returns></returns> public static string
GetExceptionAllMsg(Exception ex) { string msg = GetExceptionAllMsg(ex, 1);
return msg; } } }

Technology
©2019-2020 Toolsou All rights reserved,
java Four functional interfaces ( a key , simple )os Simple use of module Browser kernel ( understand ) Some East 14 Pay change 16 salary , Sincerity or routine ?HashMap Explain in detail It's unexpected Python Cherry tree (turtle The gorgeous style of Library )html Writing about cherry trees , Writing about cherry trees