Question: Performance overhead of throwing exception for validation Errors? #401
Replies: 7 comments 1 reply
-
Hi, I think that there is an overhead, but it is not so big. In the classic asp net, the practice of throwing exceptions was common (HttpResponseException). But I'm also interested in the topic of validation. It is not always convenient and correct to describe all the rules in Fluent Validation. What is the best way to return validation errors from the command? Throwing exceptions is not the best practice (aspnet/Mvc#4311 (comment)). Vladimir Khorikov tells it too. |
Beta Was this translation helpful? Give feedback.
-
@cantti , there are two types of validations:
|
Beta Was this translation helpful? Give feedback.
-
@maulik-modi |
Beta Was this translation helpful? Give feedback.
-
@cantti , Check CreateCustomer method here https://enterprisecraftsmanship.com/posts/functional-c-handling-failures-input-errors/ |
Beta Was this translation helpful? Give feedback.
-
@maulik-modi |
Beta Was this translation helpful? Give feedback.
-
With the modern server cpus and amounts of ram you can safely afford using exceptions instead of error pocos. The simplicity of your project will pay more. |
Beta Was this translation helpful? Give feedback.
-
@vlmironoff , Is there any possibility of crashing by firing 100 requests that causes validation error? |
Beta Was this translation helpful? Give feedback.
-
@jasontaylordev ,
What is the performance overhead of throwing ValidationException as opposed to returning errors?
According to https://enterprisecraftsmanship.com/, we should avoid throwing exceptions and return Error objects?
Beta Was this translation helpful? Give feedback.
All reactions