Chapter 6. Functional error handling
This chapter covers
- Representing alternative outcomes with Either
- Chaining operations that may fail
- Distinguishing business validation from technical errors
Error handling is an important part of our applications, and one aspect in which the functional and imperative programming
styles differ starkly:
- Imperative programming uses special statements like throw and try/catch, which disrupt the normal program flow, thus introducing side effects, as discussed in chapter 2.
- Functional programming strives to minimize side effects, so throwing exceptions is generally avoided. Instead, if an operation can fail, it should return a representation of its outcome including an indication of success or failure, ...