arrow-fx / arrow.fx / arrow.Kind / handleError

handleError

fun <A> IOOf<A>.handleError(f: (Throwable) -> A): IO<A>

Handle the error by mapping the error to a value of A.

import arrow.fx.IO
import arrow.fx.handleError

fun main(args: Array<String>) {
  //sampleStart
  val result = IO.raiseError<Int>(RuntimeException("Boom"))
    .handleError { e -> "Goodbye World! after $e" }
  //sampleEnd
  println(result.unsafeRunSync())
}

See Also

handleErrorWith

Do you like Arrow?

Arrow Org
<