safe

open fun <R> safe(block: T.() -> R): Result<R>(source)

Executes a synchronous block on the target, catching any exceptions and returning a Result.

Return

A Result containing either the successful result or the caught exception

Parameters

block

The operation to execute on the target

Type Parameters

R

The return type of the block