question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Include details in ProblemDetailsException

See original GitHub issue

As 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:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mabeadcommented, Jun 18, 2019

@khellang Please let me know once you publish an updated nuget package.

0reactions
khellangcommented, Jun 18, 2019

@mabead Pushed v3.1.0. It’s still validating, but will probably be listed Very Soon™. Thanks again! ✨

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found