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 for-comprehension
  • 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.3.1    The map function

40.3.2    The flatten function

40.3.3    The flatMap function

40.4  For-comprehension

40.5  Other operations on Try

40.6  Summary

40.7  Answers to Quick Checks