My boss prefers a system where each and every class we create has an errorCode (default value of zero) and errorMessage property defined. Each method defined in the class has validation/error trapping code which sets the error code property to an appropriate value when a problem is detected e.g. invalid value entered.
When a client instantiates one of these classes and executes one of it's methods the first thing the client should do is check the errorCode is still zero and if so continue execution. If the error code doesn't equal zero then a problem has occured and the detail of that error can be retrieved from the errorMessage property.
I prefer the idea of using the .net exception architecture and defining custom exceptions for any errors we might envisage. however, i'm struggling to understand how one can handle the above mentioned scenario because everything I read about using exceptions states that you shouldn't use exceptions for conditions that you can programatically check for. So I get that I should use try catch blocks in my client and library code for "real" exceptions but if in my method I check for example that an input parameter is of the correct type and it isn't how do i communicate this to the calling client.
With my bosses preferred approach the errorCode and the errorMessage would be set. With the exception architecture I
View Complete Post