MediatR.Extensions.FluentValidation.AspNetCore
MediatR.Extensions.FluentValidation.AspNetCore copied to clipboard
Returning errors instead of throwing?
Using exceptions for flow control is very "heavy".
Anyone figure out how to return a result with errors, instead of throwing exceptions?
You are right. But do you know any other way to pass validation failure to exception handler on middleware level?
Yes it can be done using a little bit of reflection. It feels "dirty", but it's still faster than using exceptions. (Doing it that way there is no need for exception handlers, the conversion from validation failure to HTTP response can be done in the controller.)
However I still hope there is another way, without exceptions and reflection.
(Feel free to close. Take a look at that link it's excellent.)