Include details in ProblemDetailsException
See original GitHub issueAs shown here, the ProblemDetailsException does not initialize the Exception.Message
and does not overwrite Exception.ToString()
. As a result, it is very hard to log these exceptions in a generic way.
For example, we have a generic middleware that logs all exception. It simply logs them using the standard ASP.NET Core logger:
_logger.LogDebug(ex, $"Unexpected exception: {ex.Message});
Unfortunately, for ProblemDetailsException
it only prints this:
Unexpected exctpion: Exception of type 'Hellang.Middleware.ProblemDetails.ProblemDetailsException' was thrown.`
And we don’t have any details.
What do you think about initializing the Message
property using the type and title of the problem details and including all the details in the ToString()
function? Would you be willing to accept a PR that does that?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Handling Web API Exceptions with ProblemDetails ...
In the Production environment, the middleware doesn't include these details for obvious reasons, and instead returns the basic ProblemDetails ...
Read more >Using the ProblemDetails Class in ASP.NET Core Web API
Exception Handling With the ProblemDetails Class · Define a new exception class that inherits from the ProblemDetails class and use it in the...
Read more >Handle errors in ASP.NET Core web APIs
The following code configures the app to generate a problem details response for all HTTP client and server error responses that don't have...
Read more >c# - Generate problem details inside exception filter in ASP ...
We just have to specify the title and the status code and the Problem method will fill in the rest (E.G. Type =...
Read more >How to use the ProblemDetails middleware in ASP.NET Core
The ProblemDetails middleware from Kristian Hellang handles the exceptions that occur in the request processing pipeline and converts the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@khellang Please let me know once you publish an updated nuget package.
@mabead Pushed v3.1.0. It’s still validating, but will probably be listed Very Soon™. Thanks again! ✨