liveBook · Manning

Error channel

As explained in Functional Programming in Scala, Second Edition

An error channel is a computation component that carries errors separately from ordinary result values.

An error channel carries failures separately from ordinary result values. Task adds this channel to IO, storing evaluation failures as Try values while allowing normal mapping to continue unchanged. section 15.3.2

The channel supports several compositional operations:

  • Use attempt to expose the underlying Try, including failures such as NumberFormatException. section 15.3.2
  • Use handleErrorWith to sequence recovery through the error channel, short-circuiting on Failure like Try and Either. section 15.3.2
  • Extend the same behavior to Stream and Pull; MonadThrow supplies raising and handling operations beyond Monad. section 15.3.2

How Functional Programming in Scala, Second Edition covers it

How deep it goes
Explains storage, short-circuiting, recovery, and MonadThrow, then defers detailed Pull stepping to implementation code.
Examples
Uses a failing integer conversion, Task recovery, streamed evaluation, and Pull error-handler constructors.
What it assumes
Assumes familiarity with IO, Try, Either, and Monad while defining MonadThrow as an extension of Monad.
What you can do after
Apply it via Task, Stream, or Pull to expose, recover, raise, and propagate computation failures.
How it connects
Connects IO with Try, Either, Monad, Stream, Pull, and MonadThrow.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Functional Programming in Scala, Second Edition. The section links point to the parts of the book it draws on.