Skip to main content

Handling Errors

Error handling is critical for building robust workflows that can handle non-happy paths. It allows for short-circuiting operations and following an alternative path in the presence of expected but unusual situations. It can be seen as a more convenient alternative to Forks.

Errors defined and handled should be domain errors and not technical ones. Domain errors represent business-level exceptions that are meaningful in your workflow context, rather than implementation-specific exceptions like network failures or timeouts.

val doThings: WIO[MyState, MyError, Nothing]                        =
WIO.pure.error(MyError()).autoNamed
val handleThatNastyError: WIO[(MyState, MyError), Nothing, MyState] =
WIO.pure(MyState(1)).autoNamed

val errorHandled: WIO[MyState, Nothing, MyState] =
doThings.handleErrorWith(handleThatNastyError)
Rendering Outputs