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

Missleading unhandled exception error log #54433

Closed
N3IS opened this issue Mar 8, 2024 · 3 comments
Closed

Missleading unhandled exception error log #54433

N3IS opened this issue Mar 8, 2024 · 3 comments
Labels
area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlesware design-proposal This issue represents a design proposal for a different issue, linked in the description

Comments

@N3IS
Copy link

N3IS commented Mar 8, 2024

Summary

Since we migrated our services to .NET8 we use the recommended UseExceptionHandler() middleware to deal with our exceptions. We have one handler which will handle all exceptions by logging them, creating a ProblemDetails response and return true if we were able to handle this all successful. But after some time we saw in our logs the same exception logged by the Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware logger with the message An unhandled exception has occurred while executing the request. again.
This surprised us as the exception was handled successfully by our handler which returned true. After some research we think that found the reason for this in the middleware implementation. At line 130 the exception will be logged as unhandled but the handlers are checked way later in line 173.

Motivation and goals

Our idea would be to log a exception as unhandled with level error only after all possible handlers are checked and none of them was able to handle the exception to prevent confusion of a unhandled exception error log for a already handled and logged exception.

@N3IS N3IS added the design-proposal This issue represents a design proposal for a different issue, linked in the description label Mar 8, 2024
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlesware label Mar 8, 2024
@danmoseley
Copy link
Member

@james was this an intentional choice when you added this logging?

@amcasey
Copy link
Member

amcasey commented Mar 14, 2024

@danmoseley Did you mean to tag @JamesNK?

@JamesNK
Copy link
Member

JamesNK commented May 9, 2024

Duplicate of #54554

@JamesNK JamesNK marked this as a duplicate of #54554 May 9, 2024
@JamesNK JamesNK closed this as not planned Won't fix, can't repro, duplicate, stale May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlesware design-proposal This issue represents a design proposal for a different issue, linked in the description
Projects
None yet
Development

No branches or pull requests

4 participants