Используя Custom ExceptionFilter, SendAllExceptionsToClients смог изменить это значение
publi c class demoHttpApiHostModule: AbpModule {частная константная строка DefaultCorsPolicyName = "Default";
public override void ConfigureServices(ServiceConfigurationContext context)
{
//if (hostingEnvironment.IsDevelopment())
{
context.Services.AddMvc(m => m.Filters.Add<CustomExceptionFilter>(1));
}
}
public class CustomExceptionFilter : AbpExceptionFilter
{
private readonly IExceptionToErrorInfoConverter _errorInfoConverter;
private readonly IHttpExceptionStatusCodeFinder _statusCodeFinder;
private readonly IJsonSerializer _jsonSerializer;
public ILogger<CustomExceptionFilter> Logger { get; set; }
public CustomExceptionFilter(IExceptionToErrorInfoConverter errorInfoConverter,
IHttpExceptionStatusCodeFinder statusCodeFinder,
IJsonSerializer jsonSerializer) : base(errorInfoConverter, statusCodeFinder, jsonSerializer)
{
_errorInfoConverter = errorInfoConverter;
_statusCodeFinder = statusCodeFinder;
_jsonSerializer = jsonSerializer;
Logger = NullLogger<CustomExceptionFilter>.Instance;
((DefaultExceptionToErrorInfoConverter)errorInfoConverter).SendAllExceptionsToClients = true;
}
protected override void HandleAndWrapException(ExceptionContext context)
{
//TODO: Trigger an AbpExceptionHandled event or something like that.
context.HttpContext.Response.Headers.Add(AbpHttpConsts.AbpErrorFormat, "true");
context.HttpContext.Response.StatusCode = (int)_statusCodeFinder.GetStatusCode(context.HttpContext, context.Exception);
var remoteServiceErrorInfo = _errorInfoConverter.Convert(context.Exception);
context.Result = new ObjectResult(new RemoteServiceErrorResponse(remoteServiceErrorInfo));
var logLevel = context.Exception.GetLogLevel();
Logger.LogWithLevel(logLevel, $"---------- {nameof(RemoteServiceErrorInfo)} ----------");
Logger.LogWithLevel(logLevel, _jsonSerializer.Serialize(remoteServiceErrorInfo, indented: true));
Logger.LogException(context.Exception, logLevel);
context.Exception = null; //Handled!
}
}