Throwable objects.
| Modifier and Type | Field and Description |
|---|---|
| private static final String[] | CAUSE_METHOD_NAMES
The names of methods commonly used to access a wrapped exception. |
| private static final int | |
| pack-priv static final String | WRAPPED_MARKER
Used when printing stack frames to denote the start of a wrapped exception. |
| Access | Constructor and Description |
|---|---|
| public | ExceptionUtils()
Deprecated
TODO Make private in 4.0.
Public constructor allows an instance of |
| Modifier and Type | Method and Description |
|---|---|
| public static < The type of the returned value. T extends RuntimeException> T | Returns: Never actually returned, this generic type matches any type which the calling site requires. "Returning" the results of this method, as done in the propagateExample above, will satisfy the Java compiler requirement that all code paths return a value.The throwable to rethrow. throwable)Throws the given (usually checked) exception without adding the exception to the throws clause of the calling method. |
| private static <R, T extends Throwable> R | |
| public static void | |
| public static Throwable | getCause(final Throwable
the throwable to introspect for a cause, may be null. throwable)
Deprecated
This feature will be removed in Lang 4, use
Throwable#getCause instead.
Introspects the |
| public static Throwable | getCause(final Throwable
the throwable to introspect for a cause, may be null. throwable, String[] the method names, null treated as default set. methodNames)
Deprecated
This feature will be removed in Lang 4, use
Throwable#getCause instead.
Introspects the |
| private static Throwable | Returns: the wrapped exception, ornull if not found.the exception to examine. throwable, final String the name of the method to find and invoke. methodName)Gets a |
| public static String[] | Returns: cloned array of the default method names.
Deprecated
This feature will be removed in Lang 4.
Gets the default names used when searching for the cause of an exception. |
| public static String | Returns: the message, non-null.the throwable to get a message for, null returns empty string. th)Gets a short message summarizing the exception. |
| public static Throwable | getRootCause(final Throwable
the throwable to get the root cause for, may be null. throwable)Walks the |
| public static String | Returns: the message, non-null.the throwable to get a message for, null returns empty string. throwable)Gets a short message summarizing the root cause exception. |
| public static String[] | Returns: an array of stack trace frames, never null.the throwable to examine, may be null. throwable)Gets a compact stack trace for the root cause of the supplied
|
| public static List | Returns: a list of stack trace frames, never null.the throwable to examine, may be null. throwable)Gets a compact stack trace for the root cause of the supplied |
| pack-priv static List | Returns: List of stack frames.is any throwable. throwable)Gets a |
| pack-priv static String[] | Returns: an array where each element is a line from the argument.a stack trace String. stackTrace)Gets an array where each element is a line from the argument. |
| public static String[] | Returns: an array of strings describing each stack frame, never null.the throwable)Throwable to examine, may be null.Gets the stack trace associated with the specified
|
| public static String | Returns: the stack trace as generated by the exception'sprintStackTrace(PrintWriter) method, or an empty String if null input.the throwable)Throwable to be examined, may be null.Gets the stack trace from a Throwable as a String, including suppressed and cause exceptions. |
| public static int | Returns: the count of throwables, zero on null input.the throwable to inspect, may be null. throwable)Gets a count of the number of |
| public static List | Returns: the list of throwables, never null.the throwable to inspect, may be null. throwable)Gets the list of |
| public static Throwable[] | Returns: the array of throwables, never null.the throwable to inspect, may be null. throwable)Gets the list of |
| public static boolean | Returns: true, if chain is an instance of type or is an UndeclaredThrowableException wrapping a cause.The root of a Throwable causal chain. chain, final Class<? extends Throwable> The exception type to test. type)Tests if the throwable's causal chain have an immediate or wrapped exception of the given type? |
| private static int | Returns: index of thetype within throwables nested within the specified throwable.the throwable to inspect, may be null. throwable, final Class<? extends Throwable> the type to search for, subclasses match, null returns -1. type, int the (zero-based) index of the starting position, negative treated as zero, larger than chain size returns -1. fromIndex, final boolean if subclass)true, compares with Class#isAssignableFrom(Class), otherwise compares using references.Worker method for the |
| public static int | Returns: the index into the throwable chain, -1 if no match or null input.the throwable to inspect, may be null. throwable, final Class<? extends Throwable> the class to search for, subclasses do not match, null returns -1. clazz)Returns the (zero-based) index of the first |
| public static int | Returns: the index into the throwable chain, -1 if no match or null input.the throwable to inspect, may be null. throwable, final Class<? extends Throwable> the class to search for, subclasses do not match, null returns -1. clazz, final int the (zero-based) index of the starting position, negative treated as zero, larger than chain size returns -1. fromIndex)Returns the (zero-based) index of the first |
| public static int | Returns: the index into the throwable chain, -1 if no match or null input.the throwable to inspect, may be null. throwable, final Class<? extends Throwable> the type to search for, subclasses match, null returns -1. type)Returns the (zero-based) index of the first |
| public static int | Returns: the index into the throwable chain, -1 if no match or null input.the throwable to inspect, may be null. throwable, final Class<? extends Throwable> the type to search for, subclasses match, null returns -1. type, final int the (zero-based) index of the starting position, negative treated as zero, larger than chain size returns -1. fromIndex)Returns the (zero-based) index of the first |
| public static boolean | |
| public static boolean | Returns: True if the given Throwable is an unchecked exception.The throwable to check. throwable)Checks if a throwable represents an unchecked exception |
| public static void | printRootCauseStackTrace(final Throwable
the throwable to output. throwable)Prints a compact stack trace for the root cause of a throwable
to |
| public static void | printRootCauseStackTrace(final Throwable
the throwable to output, may be null. throwable, final PrintStream the stream to output to, may not be null. printStream)Prints a compact stack trace for the root cause of a throwable. |
| public static void | printRootCauseStackTrace(final Throwable
the throwable to output, may be null. throwable, final PrintWriter the writer to output to, may not be null. printWriter)Prints a compact stack trace for the root cause of a throwable. |
| public static void | removeCommonFrames(final List<String>
stack trace of a cause throwable. causeFrames, final List<String> stack trace of a wrapper throwable. wrapperFrames)Removes common frames from the cause trace given the two stack traces. |
| public static < The type of the return value. T> T | Returns: Never actually returns, this generic type matches any type which the calling site requires. "Returning" the results of this method, as done in the propagateExample above, will satisfy the Java compiler requirement that all code paths return a value.The throwable to rethrow. throwable)Throws the given (usually checked) exception without adding the exception to the throws clause of the calling method. |
| public static Stream | |
| private static < the type of Throwable you are searching. T extends Throwable> T | Returns: throwable of thetype within throwables nested within the specified throwable.the throwable to inspect, may be null. throwable, final Class<T> the type to search, subclasses match, null returns null. type, int the (zero-based) index of the starting position,
negative treated as zero, larger than chain size returns null. fromIndex, final boolean if subclass)true, compares with Class#isAssignableFrom(Class), otherwise compares
using references.Worker method for the |
| public static < the type of Throwable you are searching. T extends Throwable> T | Returns: the first matching throwable from the throwable chain, null if no match or null input.the throwable to inspect, may be null. throwable, final Class<T> the class to search for, subclasses do not match, null returns null. clazz)Returns the first |
| public static < the type of Throwable you are searching. T extends Throwable> T | Returns: the first matching throwable from the throwable chain, null if no match or null input.the throwable to inspect, may be null. throwable, final Class<T> the class to search for, subclasses do not match, null returns null. clazz, final int the (zero-based) index of the starting position, negative treated as zero, larger than chain size returns null. fromIndex)Returns the first |
| public static < the type of Throwable you are searching. T extends Throwable> T | Returns: the first matching throwable from the throwable chain, null if no match or null input.the throwable to inspect, may be null. throwable, final Class<T> the type to search for, subclasses match, null returns null. type)Returns the throwable of the first |
| public static < the type of Throwable you are searching. T extends Throwable> T | Returns: the first matching throwable from the throwable chain, null if no match or null input.the throwable to inspect, may be null. throwable, final Class<T> the type to search for, subclasses match, null returns null. type, final int the (zero-based) index of the starting position, negative treated as zero, larger than chain size returns null. fromIndex)Returns the first |
| public static < The Throwable type. T> T | Returns: the given throwable.the throwable to test and throw or return. throwable)
Deprecated
Use
throwUnchecked(Throwable).
Tests whether the specified |
| public static < The Throwable type. T extends Throwable> T | Returns: the given throwable.the throwable to test and throw or return. throwable)Tests whether the specified |
| public static < The type of the returned value. R> R | Returns: Never actually returned, this generic type matches any type which the calling site requires. "Returning" the results of this method will satisfy the Java compiler requirement that all code paths return a value.The throwable to rethrow. throwable)Throws a checked exception without adding the exception to the throws clause of the calling method. |