Reuse runCatching in recoverCatching
This commit is contained in:
parent
d2932de547
commit
0b85cc2aad
@ -29,13 +29,7 @@ public inline infix fun <V, E> Result<V, E>.recoverCatching(transform: (E) -> V)
|
|||||||
|
|
||||||
return when (this) {
|
return when (this) {
|
||||||
is Ok -> this
|
is Ok -> this
|
||||||
is Err -> {
|
is Err -> runCatching { transform(error) }
|
||||||
try {
|
|
||||||
Ok(transform(error))
|
|
||||||
} catch (e: Throwable) {
|
|
||||||
Err(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user