Skip to content

Commit

Permalink
Set SendExceptionDataToClientTypes from options.
Browse files Browse the repository at this point in the history
  • Loading branch information
maliming committed Sep 17, 2024
1 parent 9c1c3a4 commit bdbe95b
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ protected virtual RemoteServiceErrorInfo GetErrorInfo(UserExceptionInformerConte
{
options.SendExceptionsDetailsToClients = Options.SendExceptionsDetailsToClients;
options.SendStackTraceToClients = Options.SendStackTraceToClients;
options.SendExceptionDataToClientTypes = Options.SendExceptionDataToClientTypes;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public virtual async Task<IActionResult> Index(int httpStatusCode)
{
options.SendExceptionsDetailsToClients = ExceptionHandlingOptions.SendExceptionsDetailsToClients;
options.SendStackTraceToClients = ExceptionHandlingOptions.SendStackTraceToClients;
options.SendExceptionDataToClientTypes = ExceptionHandlingOptions.SendExceptionDataToClientTypes;
});

if (httpStatusCode == 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ protected virtual void LogException(ExceptionContext context, out RemoteServiceE
{
options.SendExceptionsDetailsToClients = exceptionHandlingOptions.SendExceptionsDetailsToClients;
options.SendStackTraceToClients = exceptionHandlingOptions.SendStackTraceToClients;
options.SendExceptionDataToClientTypes = exceptionHandlingOptions.SendExceptionDataToClientTypes;
});

var remoteServiceErrorInfoBuilder = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ protected virtual async Task HandleAndWrapException(PageHandlerExecutedContext c
{
options.SendExceptionsDetailsToClients = exceptionHandlingOptions.SendExceptionsDetailsToClients;
options.SendStackTraceToClients = exceptionHandlingOptions.SendStackTraceToClients;
options.SendExceptionDataToClientTypes = exceptionHandlingOptions.SendExceptionDataToClientTypes;
});

var logLevel = context.Exception!.GetLogLevel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ await httpContext.Response.WriteAsync(
{
options.SendExceptionsDetailsToClients = exceptionHandlingOptions.SendExceptionsDetailsToClients;
options.SendStackTraceToClients = exceptionHandlingOptions.SendStackTraceToClients;
options.SendExceptionDataToClientTypes = exceptionHandlingOptions.SendExceptionDataToClientTypes;
})
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,19 @@ namespace Volo.Abp.AspNetCore.ExceptionHandling;

public class AbpExceptionHandlingOptions
{
public bool SendExceptionsDetailsToClients { get; set; } = false;
public bool SendExceptionsDetailsToClients { get; set; }

public bool SendStackTraceToClients { get; set; } = true;
public bool SendStackTraceToClients { get; set; }

public List<Type> SendExceptionDataToClientTypes { get; } = new List<Type>();
public List<Type> SendExceptionDataToClientTypes { get; set; }

public AbpExceptionHandlingOptions()
{
SendExceptionsDetailsToClients = false;
SendStackTraceToClients = true;
SendExceptionDataToClientTypes =
[
typeof(IBusinessException)
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,7 @@ protected virtual AbpExceptionHandlingOptions CreateDefaultOptions()
return new AbpExceptionHandlingOptions
{
SendExceptionsDetailsToClients = false,
SendStackTraceToClients = true,
SendExceptionDataToClientTypes =
{
typeof(IBusinessException)
}
SendStackTraceToClients = true
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public virtual Task<AuditLog> ConvertAsync(AuditLogInfo auditLogInfo)
{
options.SendExceptionsDetailsToClients = ExceptionHandlingOptions.SendExceptionsDetailsToClients;
options.SendStackTraceToClients = ExceptionHandlingOptions.SendStackTraceToClients;
options.SendExceptionDataToClientTypes = ExceptionHandlingOptions.SendExceptionDataToClientTypes;
}))
?? new List<RemoteServiceErrorInfo>();

Expand Down

0 comments on commit bdbe95b

Please sign in to comment.