//arrow-fx-stm/arrow.fx.stm/STM/catch
common abstract fun <A> catch(f: STM.() -> A, onError: STM.(Throwable) -> A): A
Run f and handle any exception thrown with onError.
import arrow.fx.stm.atomically
suspend fun main() {
//sampleStart
val result = atomically {
catch({ throw Throwable() }) { e -> "caught" }
}
//sampleEnd
println("Result $result")
}
Do you like Arrow?
✖