result

inline fun <R, E : Exception> Any.result(block: ResultBlock<R, E>.() -> R): Result<R, E>

Returns the value produced by the block parameter as a Result. If an exception is thrown within the block that matches the type declared on the Result, then that exception is returned as the result. All other exceptions will be rethrown.