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.

Not too sure how to migrate off ExceptionProblemDetails

See original GitHub issue

G’day 👋🏻

I’m migrating to v5 and noticed this warning about ExceptionProblemDetails becoming obsolete.

image

(note: ignore the code in the image, i just wanted to quickly take a screenie 😊 )

Old:

options.Map<ValidationException>(validationException => 
    new ExceptionProblemDetails(validationException, StatusCodes.Status400BadRequest));

New:

options.Map<ValidationException>(validationException => 
                    new ValidationProblemDetails(validationException.Errors.ToDictionary(key => key.PropertyName, value => new string[] { value.ErrorMessage }))
                    {
                        Status = (int)HttpStatusCode.BadRequest
                    });

I just feel that the updated way I’m doing/trying is … cumbersome?

Would love some thoughts…

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:24 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
khellangcommented, Aug 25, 2020

I’m not sure a class like that would add a lot of value. The bulk of the code for validation errors would still be in the mapping from a validation exception into the dictionary, which you’d still need to write.

1reaction
khellangcommented, Aug 25, 2020

Yeah, the problem with DictionaryKeyPolicy is that it applies to all dictionaries, which could introduce problems with round-tripping. There is an issue for handling JsonExtensionData specifically, but that hasn’t moved anywhere; https://github.com/dotnet/runtime/issues/31167.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ProblemDetails is not returned for 404NotFound and ...
Given a new ASPNET Core 2.2 "API" Website, ProblemDetails are not returned when: the route doesn't exist (404 Not found); an exception is...
Read more >
How to use the ProblemDetails middleware in ASP.NET Core
This article talks about ProblemDetails, open source ASP.NET Core middleware from Kristian Hellang that can be used to generate detailed results ...
Read more >
Using .NET 7 ProblemDetails instead of Hellang
I'm trying to migrate from Hellang ProblemDetails to a native .NET 7 ProblemDetails. Can someone explain how to replace the Hellang.
Read more >
A standard way of specifying errors in HTTP API responses
The only thing we need left is to configure ProblemDetails how to map this exception with the problem details object. Open Startup. cs...
Read more >
Using the ProblemDetails Class in ASP.NET Core Web API
Define a new exception class that inherits from the ProblemDetails class and use it in the try-catch blocks across the application ...
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