chapter forty

40    Error Handling with Try

After reading this lesson, you will be able to:

  • Represent a computation that can fail using Try
  • Decompose it using pattern matching
  • Manipulate its value using the map, flatten, and flatMap operations
  • Chain several Try instances using a for-comprehension statement
  • Check if a computation has failed and retrieve its value.

40.1       Creating a Try

40.2       Pattern Matching on Try

40.3       The map, flatten, and flatMap operations

40.4       For-comprehension

40.5       Other operation on Try

40.6       Summary

40.7       Answers to Quick Checks