dnowak
12/04/2019, 10:03 AMTry
but it is deprecated in favour of IO
or Either.catch
. But:
• I do not know how to use IO and it looks not appriopriate for such simple case
• Either.catch requires coroutines so I ended up with following function:
fun <R> attempt(f: suspend () -> R): Either<Throwable, R> = runBlocking { Either.catch { f() } }
Is there any better way to:
• call some code
• catch possible exception
• convert it to Either<Error, Result>?