O'Reilly logo

Functional Programming in C#: How to write better C# code by Enrico Buonanno

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required