KristianS93 / CommandCentral_API

API for the CommandCentral App
MIT License
0 stars 0 forks source link

Implementation of result type #83

Open KristianS93 opened 1 year ago

KristianS93 commented 1 year ago

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."

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.