public final class Throwables
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
Throwables.DiscreteAction<E extends java.lang.Exception> |
static class |
Throwables.FileOpType |
| Constructor and Description |
|---|
Throwables() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.RuntimeException |
cleaned(java.lang.Throwable t)
A shortcut for
unchecked(unwrapped(t)). |
static java.lang.Throwable |
close(java.lang.Throwable accumulate,
java.lang.Iterable<? extends java.lang.AutoCloseable> closeables) |
static java.util.Optional<java.io.IOException> |
extractIOExceptionCause(java.lang.Throwable t) |
static <T extends java.lang.Throwable> |
failIfCanCast(java.lang.Throwable fail,
java.lang.Class<T> checked) |
static boolean |
isCausedBy(java.lang.Throwable t,
java.util.function.Predicate<java.lang.Throwable> cause) |
static void |
maybeFail(java.lang.Throwable fail) |
static <T extends java.lang.Throwable> |
maybeFail(java.lang.Throwable fail,
java.lang.Class<T> checked) |
static <E extends java.lang.Exception> |
maybeFail(Throwables.DiscreteAction<? extends E>... actions) |
static <T extends java.lang.Throwable> |
merge(T existingFail,
T newFail) |
static void |
perform(java.io.File against,
Throwables.FileOpType opType,
Throwables.DiscreteAction<? extends java.io.IOException>... actions) |
static <E extends java.lang.Exception> |
perform(java.util.stream.Stream<? extends Throwables.DiscreteAction<? extends E>> stream,
Throwables.DiscreteAction<? extends E>... extra) |
static <E extends java.lang.Exception> |
perform(java.util.stream.Stream<Throwables.DiscreteAction<? extends E>> actions) |
static void |
perform(java.lang.String filePath,
Throwables.FileOpType opType,
Throwables.DiscreteAction<? extends java.io.IOException>... actions) |
static java.lang.Throwable |
perform(java.lang.Throwable accumulate,
java.util.Iterator<? extends Throwables.DiscreteAction<?>> actions) |
static <E extends java.lang.Exception> |
perform(Throwables.DiscreteAction<? extends E>... actions) |
static java.lang.Throwable |
perform(java.lang.Throwable accumulate,
java.util.stream.Stream<? extends Throwables.DiscreteAction<?>> actions) |
static java.lang.Throwable |
perform(java.lang.Throwable accumulate,
java.lang.String filePath,
Throwables.FileOpType opType,
java.util.stream.Stream<Throwables.DiscreteAction<? extends java.io.IOException>> actions) |
static java.lang.Throwable |
perform(java.lang.Throwable accumulate,
java.lang.String filePath,
Throwables.FileOpType opType,
Throwables.DiscreteAction<? extends java.io.IOException>... actions) |
static java.lang.Throwable |
perform(java.lang.Throwable accumulate,
Throwables.DiscreteAction<?>... actions) |
static java.lang.RuntimeException |
throwAsUncheckedException(java.lang.Throwable t)
throw the exception as a unchecked exception, wrapping if a checked exception, else rethroing as is.
|
static java.lang.RuntimeException |
unchecked(java.lang.Throwable t)
If the provided exception is unchecked, return it directly, otherwise wrap it into a
RuntimeException
to make it unchecked. |
static java.lang.Throwable |
unwrapped(java.lang.Throwable t)
If the provided throwable is a "wrapping" exception (see below), return the cause of that throwable, otherwise
return its argument untouched.
|
public static boolean isCausedBy(java.lang.Throwable t,
java.util.function.Predicate<java.lang.Throwable> cause)
public static <T extends java.lang.Throwable> T merge(T existingFail,
T newFail)
public static void maybeFail(java.lang.Throwable fail)
public static <T extends java.lang.Throwable> void maybeFail(java.lang.Throwable fail,
java.lang.Class<T> checked)
throws T extends java.lang.Throwable
T extends java.lang.Throwablepublic static <T extends java.lang.Throwable> boolean failIfCanCast(java.lang.Throwable fail,
java.lang.Class<T> checked)
throws T extends java.lang.Throwable
T extends java.lang.Throwable@SafeVarargs public static <E extends java.lang.Exception> void maybeFail(Throwables.DiscreteAction<? extends E>... actions)
@SafeVarargs public static <E extends java.lang.Exception> void perform(Throwables.DiscreteAction<? extends E>... actions) throws E extends java.lang.Exception
E extends java.lang.Exceptionpublic static <E extends java.lang.Exception> void perform(java.util.stream.Stream<? extends Throwables.DiscreteAction<? extends E>> stream, Throwables.DiscreteAction<? extends E>... extra) throws E extends java.lang.Exception
E extends java.lang.Exceptionpublic static <E extends java.lang.Exception> void perform(java.util.stream.Stream<Throwables.DiscreteAction<? extends E>> actions) throws E extends java.lang.Exception
E extends java.lang.Exceptionpublic static java.lang.Throwable perform(java.lang.Throwable accumulate,
Throwables.DiscreteAction<?>... actions)
public static java.lang.Throwable perform(java.lang.Throwable accumulate,
java.util.stream.Stream<? extends Throwables.DiscreteAction<?>> actions)
public static java.lang.Throwable perform(java.lang.Throwable accumulate,
java.util.Iterator<? extends Throwables.DiscreteAction<?>> actions)
@SafeVarargs
public static void perform(java.io.File against,
Throwables.FileOpType opType,
Throwables.DiscreteAction<? extends java.io.IOException>... actions)
@SafeVarargs
public static void perform(java.lang.String filePath,
Throwables.FileOpType opType,
Throwables.DiscreteAction<? extends java.io.IOException>... actions)
@SafeVarargs
public static java.lang.Throwable perform(java.lang.Throwable accumulate,
java.lang.String filePath,
Throwables.FileOpType opType,
Throwables.DiscreteAction<? extends java.io.IOException>... actions)
public static java.lang.Throwable perform(java.lang.Throwable accumulate,
java.lang.String filePath,
Throwables.FileOpType opType,
java.util.stream.Stream<Throwables.DiscreteAction<? extends java.io.IOException>> actions)
public static java.lang.Throwable close(java.lang.Throwable accumulate,
java.lang.Iterable<? extends java.lang.AutoCloseable> closeables)
public static java.util.Optional<java.io.IOException> extractIOExceptionCause(java.lang.Throwable t)
public static java.lang.Throwable unwrapped(java.lang.Throwable t)
We call a "wrapping" exception in the context of that method an exception whose only purpose is to wrap another
exception, and currently this method recognize only 2 exception as "wrapping" ones: ExecutionException
and CompletionException.
public static java.lang.RuntimeException unchecked(java.lang.Throwable t)
RuntimeException
to make it unchecked.public static java.lang.RuntimeException throwAsUncheckedException(java.lang.Throwable t)
public static java.lang.RuntimeException cleaned(java.lang.Throwable t)
unchecked(unwrapped(t)). This is called "cleaned" because this basically removes the annoying
cruft surrounding an exception :).Copyright © 2009-2020 The Apache Software Foundation