Better Error Message in ControllerBase.ValidationProblem #15166
Labels
area-mvc
Includes: MVC, Actions and Controllers, Localization, CORS, most templates
Done
This issue has been fixed
help wanted
Up for grabs. We would accept a PR to help resolve this issue
task
Projects
Milestone
Describe the bug
During Unit Tests, I was getting a NullReferenceExeption in ControllerBase.ValidationProblem. Difficult to narrow down the problem.
To Reproduce
Steps to reproduce the behavior:
ProblemDetailsFactory
being null, asProblemDetailsFactory => HttpContext?.RequestServices?.GetRequiredService<ProblemDetailsFactory>()
silently returns null.Expected behavior
Error message should be actual problem. NullReferenceException is not clear. Perhaps check for null when returning
ProblemDetailsFactory
property.Additional context
Add any other context about the problem here.
Include the output of
dotnet --info
The text was updated successfully, but these errors were encountered: