catch

inline fun <Success> catch(block: () -> Success): Result<Success, Throwable>

Inline function to catch exceptions from a block of code and return a Result.

Return

A Result, which is a Success containing the return value of the block if it completes normally, or a Failure containing the exception if an exception is thrown.

Parameters

block

The block of code to execute.