0PricingLogin
Scala for Backend Engineering & Functional Programming · Lesson

Option, Try, Either for Errors

Implement robust error handling using `Option` for absence of value, `Try` for exceptions, and `Either` for distinct failure/success paths.

Handling Errors Gracefully

In programming, things don't always go as planned. Files might not exist, network requests could fail, or calculations might lead to invalid results.

  • How do we write robust code that can handle these situations gracefully?
  • Scala provides powerful tools to manage errors and missing values without resorting to `null` or throwing exceptions everywhere.

The Problem with Null

Many languages use null to represent the absence of a value. However, null is a common source of bugs like the dreaded NullPointerException.

Scala discourages the use of null. Instead, it offers types that explicitly state whether a value might be missing, making your code safer and easier to understand.

All lessons in this course

  1. Immutable Collections Deep Dive
  2. Functional Operations on Collections
  3. Option, Try, Either for Errors
← Back to Scala for Backend Engineering & Functional Programming