Software systems are complex, and we can’t handle every conceivable error using types like this, nor would we want to. So before we do anything else, let’s come up with a consistent approach to classifying and handling errors.
We can classify errors into three groups:
Domain Errors. These are errors that are to be expected as part of the business process and therefore must be included in the design of the domain, such as an order that is rejected by billing or an order that contains an invalid product code. The business will already have procedures in place to deal with this kind of thing, and the code will need to reflect these processes.
Panics. These are errors that leave the system in an unknown state, such as ...