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, ...
Get Functional Programming in C# now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.