Browse Source

Merge pull request #19268 from abpframework/ExceptionHandled

Skip handle exception when `ExceptionHandled` is `true`.
pull/19508/head
Halil İbrahim Kalkan 3 years ago
committed by GitHub
parent
commit
6ba5245323
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 7
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/AbpExceptionFilter.cs
  2. 7
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/AbpExceptionPageFilter.cs

7
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/AbpExceptionFilter.cs

@ -36,6 +36,11 @@ public class AbpExceptionFilter : IAsyncExceptionFilter, IAbpFilter, ITransientD
{ {
//TODO: Create DontWrap attribute to control wrapping..? //TODO: Create DontWrap attribute to control wrapping..?
if (context.ExceptionHandled)
{
return false;
}
if (context.ActionDescriptor.IsControllerAction() && if (context.ActionDescriptor.IsControllerAction() &&
context.ActionDescriptor.HasObjectResult()) context.ActionDescriptor.HasObjectResult())
{ {
@ -78,7 +83,7 @@ public class AbpExceptionFilter : IAsyncExceptionFilter, IAbpFilter, ITransientD
context.Result = new ObjectResult(new RemoteServiceErrorResponse(remoteServiceErrorInfo)); context.Result = new ObjectResult(new RemoteServiceErrorResponse(remoteServiceErrorInfo));
} }
context.Exception = null!; //Handled! context.ExceptionHandled = true; //Handled!
} }
protected virtual void LogException(ExceptionContext context, out RemoteServiceErrorInfo remoteServiceErrorInfo) protected virtual void LogException(ExceptionContext context, out RemoteServiceErrorInfo remoteServiceErrorInfo)

7
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/AbpExceptionPageFilter.cs

@ -70,6 +70,11 @@ public class AbpExceptionPageFilter : IAsyncPageFilter, IAbpFilter, ITransientDe
{ {
//TODO: Trigger an AbpExceptionHandled event or something like that. //TODO: Trigger an AbpExceptionHandled event or something like that.
if (context.ExceptionHandled)
{
return;
}
var exceptionHandlingOptions = context.GetRequiredService<IOptions<AbpExceptionHandlingOptions>>().Value; var exceptionHandlingOptions = context.GetRequiredService<IOptions<AbpExceptionHandlingOptions>>().Value;
var exceptionToErrorInfoConverter = context.GetRequiredService<IExceptionToErrorInfoConverter>(); var exceptionToErrorInfoConverter = context.GetRequiredService<IExceptionToErrorInfoConverter>();
var remoteServiceErrorInfo = exceptionToErrorInfoConverter.Convert(context.Exception!, options => var remoteServiceErrorInfo = exceptionToErrorInfoConverter.Convert(context.Exception!, options =>
@ -106,6 +111,6 @@ public class AbpExceptionPageFilter : IAsyncPageFilter, IAbpFilter, ITransientDe
context.Result = new ObjectResult(new RemoteServiceErrorResponse(remoteServiceErrorInfo)); context.Result = new ObjectResult(new RemoteServiceErrorResponse(remoteServiceErrorInfo));
} }
context.Exception = null; //Handled! context.ExceptionHandled = true; //Handled!
} }
} }

Loading…
Cancel
Save