inline fun <R> runCatching(block: () -> R): Result<R>
Calls the specified function block and returns its encapsulated result if invocation was successful, catching and encapsulating any thrown exception as a failure.
inline fun <T, R> T.runCatching(block: T.() -> R): Result<R>
Calls the specified function block with this
value as its receiver and returns its encapsulated result if invocation was successful, catching and encapsulating any thrown exception as a failure.
© 2010–2019 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/run-catching.html