using System; using System.Net; using Volo.Abp.Http; namespace Sanhe.Abp.Wrapper; /// /// 异常包装上下文。 /// public class ExceptionWrapContext { /// /// 异常 /// public Exception Exception { get; } /// /// 服务提供器 /// public IServiceProvider ServiceProvider { get; } /// /// 用于存储有关错误的信息 /// public RemoteServiceErrorInfo ErrorInfo { get; } /// /// 状态码 /// public HttpStatusCode? StatusCode { get; set; } public ExceptionWrapContext( Exception exception, RemoteServiceErrorInfo errorInfo, IServiceProvider serviceProvider, HttpStatusCode? statusCode = null) { Exception = exception; ErrorInfo = errorInfo; ServiceProvider = serviceProvider; StatusCode = statusCode; } public ExceptionWrapContext WithCode(string code) { ErrorInfo.Code = code; return this; } public ExceptionWrapContext WithMessage(string message) { ErrorInfo.Message = message; return this; } public ExceptionWrapContext WithDetails(string details) { ErrorInfo.Details = details; return this; } public ExceptionWrapContext WithData(string key, object value) { ErrorInfo.Data[key] = value; return this; } }