0PricingLogin
Scala for Backend Engineering & Functional Programming · Lesson

Error and Dependency Channels

Typed errors and env.

Two Powerful Channels

Beyond the success value, ZIO[R, E, A] tracks a typed error channel E and a dependency channel R. Both are visible in the type, making failures and requirements explicit at compile time.

Typed Errors

Model domain failures as a sealed hierarchy and put it in E. The compiler then forces you to handle exactly those cases.

import zio._

sealed trait AppError
case object NotFound extends AppError
case object Forbidden extends AppError

val lookup: IO[AppError, String] = ZIO.fail(NotFound)

All lessons in this course

  1. The ZIO Effect
  2. Composing ZIO
  3. Error and Dependency Channels
  4. Running ZIO Apps
← Back to Scala for Backend Engineering & Functional Programming