crummy
05/18/2020, 12:41 AMEither<>
class)crummy
05/18/2020, 12:57 AMJulio Barros
05/18/2020, 4:05 AMMike
05/18/2020, 11:51 AMEither
approach is more functional
, and more explicit. This is a great approach for expected exceptions
, meaning business logic/validation failures. The caller explicitly knows that what it's calling could fail in some way, and the ways are explicitly defined by the return value. It can also be cleanly handled, OR passed up the chain.
Exceptions are good for critical failure, or unexpected failures where you generally don't want to clutter your code with handling mechanisms. Out of memory and other system failures are a good example of this.
Personally, I go for this hybrid approach. They both have their place.