Skip to content

Commit

Permalink
Reuse runCatching in recoverCatching
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbull committed Mar 8, 2024
1 parent d2932de commit 0b85cc2
Showing 1 changed file with 1 addition and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
}

Expand Down

0 comments on commit 0b85cc2

Please sign in to comment.