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();
|
}
|
}
|
}
|