Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nilsmagnus/84e6658a166552e14ab669a1b5930bd8 to your computer and use it in GitHub Desktop.
Save nilsmagnus/84e6658a166552e14ab669a1b5930bd8 to your computer and use it in GitHub Desktop.
run a block and return result wrapped in an arrow.Either<Throwable,R>
import arrow.core.Either
public inline fun <R> catch(block: () -> R): Either<Throwable,R> {
return try {
Either.right(block())
} catch (e: Throwable) {
Either.left(e)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment