CarterCommunity / Carter

Carter is framework that is a thin layer of extension methods and functionality over ASP.NET Core allowing code to be more explicit and most importantly more enjoyable.
MIT License
2.06k stars 174 forks source link

Provide a message when Validate cannot resolve a Validator #258

Closed ggmueller closed 3 years ago

ggmueller commented 3 years ago

At the moment Carter throws an NullReferenceException when no validator can be resolved from the ValidatorLocator. The NullReferenceException contains no further information as to why this Exception was thrown.

I suggest to add an informative message, so that the developer can find the reason for the exception.

I also suggest throwing an InvalidOperationException here, as null is not dereferenced in this case.

jchannon commented 3 years ago

Thanks!! 👍