It appears that using exceptions for common error handling, validation error handling as such is not very smart, and should primarily be used for more critical errors.
Microsoft specifies:
"Use exception handling if the event doesn't occur often, that is, if the event is truly exceptional and indicates an error, such as an unexpected end-of-file. When you use exception handling, less code is executed in normal conditions."
Another approach for handling the errors in the API would be to implement a Result type.
The result type should basically be a class with 2 overloads for either the T: Type for succes or for the an exception, this means that exceptions will be made, but not thrown, such that it is possible to check the result for either a succes or an error.
The performance gain described by Nick Chapsas youtube, is almost double doing stresstesting.
It appears that using exceptions for common error handling, validation error handling as such is not very smart, and should primarily be used for more critical errors.
Microsoft specifies:
MS docs
Another approach for handling the errors in the API would be to implement a Result type. The result type should basically be a class with 2 overloads for either the T: Type for succes or for the an exception, this means that exceptions will be made, but not thrown, such that it is possible to check the result for either a succes or an error.
The performance gain described by Nick Chapsas youtube, is almost double doing stresstesting.