Package com.chutneytesting.tools
Class Try<T>
- java.lang.Object
-
- com.chutneytesting.tools.Try<T>
-
public class Try<T> extends Object
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T,E extends Exception>
Try<T>exec(ThrowingSupplier<T,E> builder)Tget()ExceptiongetError()Try<T>ifFailed(Consumer<Exception> errorHandler)Try<T>ifSuccess(Consumer<T> valueHandler)Truntime()Try<T>tryToRecover(ThrowingFunction<? super Exception,T,? extends Exception> recoverFunction)<Handled extends Exception>
Try<T>tryToRecover(Class<Handled> handledClass, ThrowingFunction<? super Exception,T,? extends Exception> recoverFunction)static <T,E extends Exception>
Tunsafe(ThrowingSupplier<T,E> block)static <T,E extends Exception>
Tunsafe(String message, ThrowingSupplier<T,E> block)
-
-
-
Method Detail
-
unsafe
public static <T,E extends Exception> T unsafe(ThrowingSupplier<T,E> block)
-
unsafe
public static <T,E extends Exception> T unsafe(String message, ThrowingSupplier<T,E> block)
-
exec
public static <T,E extends Exception> Try<T> exec(ThrowingSupplier<T,E> builder)
-
runtime
public T runtime()
-
get
public T get() throws IllegalStateException
- Throws:
IllegalStateException
-
getError
public Exception getError() throws IllegalStateException
- Throws:
IllegalStateException
-
tryToRecover
public <Handled extends Exception> Try<T> tryToRecover(Class<Handled> handledClass, ThrowingFunction<? super Exception,T,? extends Exception> recoverFunction)
-
tryToRecover
public Try<T> tryToRecover(ThrowingFunction<? super Exception,T,? extends Exception> recoverFunction)
-
-