예제 #1
0
 private static void FormatHandlingException(StringWriter writer, string header, Exception ex)
 {
     if (ex != null)
     {
         writer.WriteLine();
         writer.WriteLine(header);
         writer.Write(writer.NewLine);
         TextExceptionFormatter formatter = new TextExceptionFormatter(writer, ex);
         formatter.Format();
     }
 }
 private static void FormatHandlingException(StringWriter writer, string header, Exception ex)
 {
     if (ex != null)
     {
         writer.WriteLine();
         writer.WriteLine(header);
         writer.Write(writer.NewLine);
         TextExceptionFormatter formatter = new TextExceptionFormatter(writer, ex);
         formatter.Format();
     }
 }
        /// <summary>
        /// ��TextExceptionFormatter��ʽ��Exception������ʾ
        /// </summary>
        /// <param name="ex"></param>
        /// <returns></returns>
        public static string FormatException(Exception ex)
        {
            StringBuilder sb = new StringBuilder();
            StringWriter writer = new StringWriter(sb);

            Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter formatter
                = new Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter(writer, ex);

            // Format the exception
            formatter.Format();

            return sb.ToString();
        }
        /// <summary>
        /// 用TextExceptionFormatter格式化Exception错误提示
        /// </summary>
        /// <param name="ex"></param>
        /// <returns></returns>
        public static string FormatException(Exception ex)
        {
            StringBuilder sb     = new StringBuilder();
            StringWriter  writer = new StringWriter(sb);

            Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter formatter
                = new Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter(writer, ex);

            // Format the exception
            formatter.Format();

            return(sb.ToString());
        }