Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log exception on AbpExceptionFilter. #16071

Merged
merged 1 commit into from
Mar 24, 2023
Merged

Log exception on AbpExceptionFilter. #16071

merged 1 commit into from
Mar 24, 2023

Conversation

maliming
Copy link
Member

@maliming maliming commented Mar 24, 2023

The default exception middleware(UseDeveloperExceptionPage UseErrorPage) can't write detailed exceptions to logs if the return type is not object.

[ERR] An unhandled exception has occurred while executing the request.
Volo.Abp.BusinessException: Exception of type 'Volo.Abp.BusinessException' was thrown.

   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)


[ERR] An unhandled exception has occurred while executing the request.
Volo.Abp.BusinessException: Exception of type 'Volo.Abp.BusinessException' was thrown.

   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|8_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)

After that

[16:57:25 INF] Executing handler method MyCompanyName.MyProjectName.Web.Pages.IndexModel.OnGet - ModelState is Valid
[16:57:25 WRN] ---------- RemoteServiceErrorInfo ----------
{
  "code": "10001",
  "message": "An internal error occurred during your request!",
  "details": null,
  "data": {},
  "validationErrors": null
}

[16:57:25 WRN] Exception of type 'Volo.Abp.BusinessException' was thrown.
Volo.Abp.BusinessException: Exception of type 'Volo.Abp.BusinessException' was thrown.
   at MyCompanyName.MyProjectName.Web.Pages.IndexModel.OnGet() in abp/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/Index.cshtml.cs:line 10
   at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory.VoidHandlerMethod.Execute(Object receiver, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeHandlerMethodAsync()
   at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeNextPageFilterAsync()
   at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Rethrow(PageHandlerExecutedContext context)
   at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeInnerFilterAsync()
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ExceptionContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeNextResourceFilter()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Volo.Abp.AspNetCore.Serilog.AbpSerilogMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) in abp/framework/src/Volo.Abp.AspNetCore.Serilog/Volo/Abp/AspNetCore/Serilog/AbpSerilogMiddleware.cs:line 65
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
[16:57:25 WRN] Code:10001
[16:57:25 WRN] Details:
[16:57:25 ERR] An unhandled exception has occurred while executing the request.
Volo.Abp.BusinessException: Exception of type 'Volo.Abp.BusinessException' was thrown.

   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|8_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)

@maliming maliming requested a review from hikalkan March 24, 2023 09:00
@maliming maliming added this to the 7.2-preview milestone Mar 24, 2023
@codecov
Copy link

codecov bot commented Mar 24, 2023

Codecov Report

Merging #16071 (34bcaa9) into dev (b36c9ad) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##              dev   #16071   +/-   ##
=======================================
  Coverage   49.41%   49.41%           
=======================================
  Files        3383     3383           
  Lines      104680   104684    +4     
=======================================
+ Hits        51724    51728    +4     
  Misses      52956    52956           
Impacted Files Coverage Δ
...etCore/Mvc/ExceptionHandling/AbpExceptionFilter.cs 92.45% <100.00%> (+0.61%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@hikalkan hikalkan merged commit de4eba4 into dev Mar 24, 2023
@hikalkan hikalkan deleted the AbpExceptionFilter branch March 24, 2023 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants