Modifier and Type | Method and Description |
---|---|
<T> Try<T> |
on(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. |
public <T> Try<T> on(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 Try.throwError
to ensure critial Errors are thrown and not captured.
class Try.Success
,
class Try.Failure
,
Throwable,
Try.throwError
,
Error