Package org.elasticsearch
Class ExceptionsHelper
java.lang.Object
org.elasticsearch.ExceptionsHelper
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ElasticsearchException
static RuntimeException
static String
Deprecated.Don't swallow exceptions, allow them to propagate.static String
formatStackTrace(StackTraceElement[] stackTrace)
static ShardOperationFailedException[]
groupBy(ShardOperationFailedException[] failures)
Deduplicate the failures by exception message and index.static void
maybeDieOnAnotherThread(Throwable throwable)
If the specified cause is an unrecoverable error, this method will rethrow the cause on a separate thread so that it can not be caught and bubbles up to the uncaught exception handler.maybeError(Throwable cause)
Unwrap the specified throwable looking for any suppressed errors or errors as a root cause of the specified throwable.static <T extends Throwable>
voidmaybeThrowRuntimeAndSuppress(List<T> exceptions)
Throws a runtime exception with all given exceptions added as suppressed.static <T extends Throwable>
voidrethrowAndSuppress(List<T> exceptions)
Rethrows the first exception in the list and adds all remaining to the suppressed list.static boolean
Throws the specified exception.static String
stackTrace(Throwable e)
static RestStatus
static Throwable
Looks at the given Throwable and its cause(s) and returns the first Throwable that is of one of the given classes ornull
if no matching Throwable is found.static Throwable
unwrapCause(Throwable t)
unwrapCausesAndSuppressed(Throwable cause, Predicate<Throwable> predicate)
static IOException
Looks at the given Throwable's and its cause(s) as well as any suppressed exceptions on the Throwable as well as its causes and returns the first corruption indicating exception (as defined byCORRUPTION_EXCEPTIONS
) it finds.static <T extends Throwable>
TuseOrSuppress(T first, T second)
-
Constructor Details
-
ExceptionsHelper
public ExceptionsHelper()
-
-
Method Details
-
convertToRuntime
-
convertToElastic
-
status
-
unwrapCause
-
detailedMessage
Deprecated.Don't swallow exceptions, allow them to propagate. -
stackTrace
-
formatStackTrace
-
rethrowAndSuppress
Rethrows the first exception in the list and adds all remaining to the suppressed list. If the given list is empty no exception is thrown- Throws:
T extends Throwable
-
maybeThrowRuntimeAndSuppress
Throws a runtime exception with all given exceptions added as suppressed. If the given list is empty no exception is thrown -
useOrSuppress
-
unwrapCorruption
Looks at the given Throwable's and its cause(s) as well as any suppressed exceptions on the Throwable as well as its causes and returns the first corruption indicating exception (as defined byCORRUPTION_EXCEPTIONS
) it finds.- Parameters:
t
- Throwable- Returns:
- Corruption indicating exception if one is found, otherwise
null
-
unwrap
Looks at the given Throwable and its cause(s) and returns the first Throwable that is of one of the given classes ornull
if no matching Throwable is found. UnlikeunwrapCorruption(java.lang.Throwable)
this method does only check the given Throwable and its causes but does not look at any suppressed exceptions.- Parameters:
t
- Throwableclazzes
- Classes to look for- Returns:
- Matching Throwable if one is found, otherwise
null
-
reThrowIfNotNull
Throws the specified exception. If null if specified thentrue
is returned. -
unwrapCausesAndSuppressed
-
maybeError
Unwrap the specified throwable looking for any suppressed errors or errors as a root cause of the specified throwable.- Parameters:
cause
- the root throwable- Returns:
- an optional error if one is found suppressed or a root cause in the tree rooted at the specified throwable
-
maybeDieOnAnotherThread
If the specified cause is an unrecoverable error, this method will rethrow the cause on a separate thread so that it can not be caught and bubbles up to the uncaught exception handler. Note that the cause tree is examined for anyError
. SeemaybeError(Throwable)
for the semantics.- Parameters:
throwable
- the throwable to possibly throw on another thread
-
groupBy
Deduplicate the failures by exception message and index.
-