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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
12 additions and
2 deletions
-
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/AbpExceptionFilter.cs
-
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/AbpExceptionPageFilter.cs
|
|
|
@ -36,6 +36,11 @@ public class AbpExceptionFilter : IAsyncExceptionFilter, IAbpFilter, ITransientD |
|
|
|
{ |
|
|
|
//TODO: Create DontWrap attribute to control wrapping..?
|
|
|
|
|
|
|
|
if (context.ExceptionHandled) |
|
|
|
{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
if (context.ActionDescriptor.IsControllerAction() && |
|
|
|
context.ActionDescriptor.HasObjectResult()) |
|
|
|
{ |
|
|
|
@ -78,7 +83,7 @@ public class AbpExceptionFilter : IAsyncExceptionFilter, IAbpFilter, ITransientD |
|
|
|
context.Result = new ObjectResult(new RemoteServiceErrorResponse(remoteServiceErrorInfo)); |
|
|
|
} |
|
|
|
|
|
|
|
context.Exception = null!; //Handled!
|
|
|
|
context.ExceptionHandled = true; //Handled!
|
|
|
|
} |
|
|
|
|
|
|
|
protected virtual void LogException(ExceptionContext context, out RemoteServiceErrorInfo remoteServiceErrorInfo) |
|
|
|
|
|
|
|
@ -70,6 +70,11 @@ public class AbpExceptionPageFilter : IAsyncPageFilter, IAbpFilter, ITransientDe |
|
|
|
{ |
|
|
|
//TODO: Trigger an AbpExceptionHandled event or something like that.
|
|
|
|
|
|
|
|
if (context.ExceptionHandled) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
var exceptionHandlingOptions = context.GetRequiredService<IOptions<AbpExceptionHandlingOptions>>().Value; |
|
|
|
var exceptionToErrorInfoConverter = context.GetRequiredService<IExceptionToErrorInfoConverter>(); |
|
|
|
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.Exception = null; //Handled!
|
|
|
|
context.ExceptionHandled = true; //Handled!
|
|
|
|
} |
|
|
|
} |
|
|
|
|