EarthCitizen
01/10/2020, 10:01 AMEither.catch()
from inside Either.fx { }
? …I see an error about restricted suspending functions, but I don’t understand how to see what can be called from within Either.fx { }
…I am currently getting around the problem by doing this, but I don’t know if it is safe to do:
fun <L, R> Either.Companion.catchSafely(
mapper: (Throwable) -> L,
block: () -> R): Either<L, R> =
runBlocking {
catch(
suspend { block() }
)
}.mapLeft(mapper)
raulraja
01/10/2020, 11:17 AMraulraja
01/10/2020, 11:17 AMraulraja
01/10/2020, 11:18 AMEarthCitizen
01/10/2020, 4:44 PM