Comments (8)
Hi @ismaelbl! 👋🏻
I don't understand what the issue is. You've configured the middleware to rethrow ArgumentException
. Why do you think it's an issue when an ArgumentException
has been rethrown and logged in the request logging middleware?
from middleware.
Hi @khellang. The problem it seems the same described in #104. The actual logging works fine, but it should just write this part:
NT|WEBAP|Aplicación|Anónimo|2023-01-23 16:06:18|Estado: 500|System.ArgumentException: patata
at ClasesSenFume.Api.Controllers.CentrosController.GetAll(CentroFilterViewModel filter) in C:\Users\ismaelbl\Desktop\Proyectos\ClasesSenFume\sw-csf\src\ClasesSenFume.Api\Controllers\CentrosController.cs:line 48
at lambda_method(Closure , Object )
at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult()
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Hellang.Middleware.ProblemDetails.ProblemDetailsMiddleware.Invoke(HttpContext context)
at Hellang.Middleware.ProblemDetails.ProblemDetailsMiddleware.HandleException(HttpContext context, ExceptionDispatchInfo edi)
at Hellang.Middleware.ProblemDetails.ProblemDetailsMiddleware.Invoke(HttpContext context)
at Serilog.AspNetCore.RequestLoggingMiddleware.Invoke(HttpContext httpContext)
The entry below the first one seems to be produced by the aforementioned issue.
from middleware.
#104 is a completely different issue. The issue was that even though the exception was rethrown, the response ended up being empty.
from middleware.
Ok, I thought it might have to do with the other issue because it's printting the Connection id "0HMNTADB12UF5", Request id "0HMNTADB12UF5:00000001": An unhandled exception was thrown by the application.
message.
Sorry if it's not the case, does it occur to you what could be happening? Thanks.
from middleware.
It's hard to say what's happening as the code is incomplete and I don't know what the response looks like. To me, it looks like the request logging and problem details middleware are doing what they're supposed/configured to.
from middleware.
Yes, it actually working as I spected, but for some reason it's printting two times the same exception. In the last one without the intervention of request logging. I will try to dig up more information next week.
from middleware.
Hi, there. In the end the problem was caused by Serilog request logging. I solved it following serilog/serilog-aspnetcore#270. Instead of rethrowing the exception I set it via IDiagnosticContext
.
from middleware.
Good approach. I faced a similar issue and came up with a small library containing trivial middleware that sets exceptions in IDiagnosticContext
before ProblemDetails handles them.
from middleware.
Related Issues (20)
- Disable ProblemDetailsResultFilter with condition like UseWhen (middleware) to support backwards compatibility HOT 1
- Does not work in .net 6 HOT 8
- How to show (AddProblemDetails) multiple validation error against single property using Fluent Validation & MediatR Pipeline Behaviour HOT 3
- `MapStatusCode` not respected for MVC validation errors HOT 1
- How can I use UseMemberCasing to serialize my data
- Ambiguous invocation in .Net 7 HOT 3
- Customize Exception Logging
- How to disable developer exception page middleware? HOT 3
- Changes in ASP.NET Core v7 HOT 3
- Master Branch not building in VS 2022 HOT 8
- ProblemDetailsMiddleware and DiagnosticListener.Write for handled exceptions
- [Feature request] ProblemDetails middleware allow send Detail property out of the box in Production HOT 2
- How to customise the ProblemDetails object when capturing FluentValidation exceptions? HOT 5
- Why are headers cleared at all by the middleware?
- ProblemDetails "Instance" property is not being set HOT 13
- How can I avoid returning internal class information in error?
- AddNewtonsoftJson and ProblemDetails using NET 6 HOT 1
- Add .NET 8 support for Authentication.JwtBearer.Google HOT 1
- [Feature request] Use custom mappers inside ProblemDetailsResultFilter
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from middleware.