Reuse runCatching in recoverCatching

This commit is contained in:
Michael Bull 2024-03-08 20:29:41 +00:00
parent d2932de547
commit 0b85cc2aad

View File

@ -29,13 +29,7 @@ public inline infix fun <V, E> Result<V, E>.recoverCatching(transform: (E) -> V)
return when (this) {
is Ok -> this
is Err -> {
try {
Ok(transform(error))
} catch (e: Throwable) {
Err(e)
}
}
is Err -> runCatching { transform(error) }
}
}