Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example 1 Helper
internal suspend inline fun <T> getResult(block: () -> T): Result<T> = try {
block().let { Result.success(it) }
} catch (e: Exception) {
// Ensure coroutine cancellation can propagate to parent coroutine
if (e is CancellationException) throw e
// TODO Log with diagnostic information
Result.failure(e)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment