1
z8018
2025-06-10 e46aa927d231af83724683c7286d9db503e24cf7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace WIDESEAWCS_Common
{
    public static class ExceptionHelper
    {
        public static string ExceptionToString(this Exception ex)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append(Environment.NewLine);
            builder.Append("错误信息:");
            builder.Append(ex.Message);
            builder.Append(Environment.NewLine);
            builder.Append("错误源:");
            builder.Append(ex.Source);
            builder.Append(Environment.NewLine);
            builder.Append("错误堆栈:");
            builder.Append(ex.StackTrace);
            builder.Append(Environment.NewLine);
            builder.Append("错误类型:");
            builder.Append(ex.GetType().ToString());
            builder.Append(Environment.NewLine);
            builder.Append("错误方法:");
            builder.Append(ex.TargetSite?.ToString());
            builder.Append("InnerException:");
            builder.Append(ex.InnerException?.ToString());
            builder.Append(Environment.NewLine);
            builder.Append(Environment.NewLine);
            return builder.ToString();
        }
    }
}