@JvmStatic @NotNull public <T> Try<T> on(@NotNull kotlin.jvm.functions.Function0<? extends T> body)
Executes the given block of code and returns a class Try.Success
capturing the result, or a class Try.Failure
if a Throwable is thrown.
It is recommended this be chained with throwError
to ensure critial Errors are thrown and not captured.
class Try.Success
,
class Try.Failure
,
Throwable,
throwError
,
Error