7 Handling errors and exceptions
In this chapter
- Holding error information with the
Either
type - Handling errors with the biased
Result
type - Accessing and manipulating
Result
data - Lifting functions to operate on
Result
In chapter 6, you learned how to deal with optional data without having to manipulate null
references using the Option
data type. As you saw, this data type is perfect for dealing with the absence of data when that isn’t the result of an error. But it’s not an efficient way to handle errors because, although it allows you to cleanly report the absence of data, it swallows the cause of the absence. All missing data is treated the same way, and it’s up to the caller to try to figure out what happened. Often, this is impossible. ...
Get The Joy of Kotlin 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.