zoukankan      html  css  js  c++  java
  • c# Exception 异常信息归整

      private string ErrorMessage(Exception exception)
            {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.AppendLine("====================EXCEPTION====================");
                stringBuilder.AppendLine("【Message】:" + exception.Message);
                stringBuilder.AppendLine("【Source】:" + exception.Source);
                stringBuilder.AppendLine("【TargetSite】:" + ((exception.TargetSite != null) ? exception.TargetSite.Name : "无"));
                stringBuilder.AppendLine("【StackTrace】:" + exception.StackTrace);
                stringBuilder.AppendLine("【exception】:" + exception);
                stringBuilder.AppendLine("=================================================");
                if (exception.InnerException != null)
                {
                    stringBuilder.AppendLine("====================INNER EXCEPTION====================");
                    stringBuilder.AppendLine("【Message】:" + exception.InnerException.Message);
                    stringBuilder.AppendLine("【Source】:" + exception.InnerException.Source);
                    stringBuilder.AppendLine("【TargetSite】:" + ((exception.InnerException.TargetSite != null) ? exception.InnerException.TargetSite.Name : "无"));
                    stringBuilder.AppendLine("【StackTrace】:" + exception.InnerException.StackTrace);
                    stringBuilder.AppendLine(("【InnerException】:" + exception.InnerException) ?? "");
                    stringBuilder.AppendLine("=================================================");
                }
                return stringBuilder.ToString().Replace("/r", "").Replace("/n", "");
            }
    

      

  • 相关阅读:
    【测试方法】之模拟cpu/mem/io使用率
    【数据库原理】之clickhouse学习笔记
    python每日一练
    栈的压入、弹出序列
    包含min函数的栈
    顺时针打印矩阵
    二叉树的镜像
    树的子结构*
    调整数组顺序使奇数位于偶数前面
    在O(1)时间内删除链表节点
  • 原文地址:https://www.cnblogs.com/oceanwang/p/5806929.html
Copyright © 2011-2022 走看看