Not too sure how to migrate off ExceptionProblemDetails
See original GitHub issueG’day 👋🏻
I’m migrating to v5 and noticed this warning about ExceptionProblemDetails
becoming obsolete.
(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:
- Created 3 years ago
- Comments:24 (14 by maintainers)
Top 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 >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
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.
Yeah, the problem with
DictionaryKeyPolicy
is that it applies to all dictionaries, which could introduce problems with round-tripping. There is an issue for handlingJsonExtensionData
specifically, but that hasn’t moved anywhere; https://github.com/dotnet/runtime/issues/31167.