public class ExceptionUtils extends Object
Modifier and Type | Method and Description |
---|---|
static String |
filterStackTrace(String stackTrace,
String... packagesToStrip) |
static String |
getCallingClassName(String... classNamesToSkip)
The current class name on top of the current method call stack,
ignoring any classes in the given list of classes to skip.
|
static int |
getLineNumber(Throwable throwable,
String className)
The top-level line number within the given class name on which
this exception occurred.
|
static int |
getLineNumber(Throwable throwable,
String className,
String methodName)
The top-level line number within the given class and method name
on which this exception occurred in the given method.
|
static String |
getMethodName(Throwable throwable,
String className)
The current method name within the given class name that is
highest on the current method call stack.
|
static Throwable |
getUnderlyingCause(Throwable t)
The true cause of an exception that has occurred.
|
static String |
stackTraceToString()
The current stack trace as a multi-line String.
|
static String |
stackTraceToString(int lines)
The current stack trace as a multi-line String.
|
static String |
stackTraceToString(Throwable throwable)
The stack trace of the given exception as a multi-line String.
|
static String |
stackTraceToString(Throwable throwable,
int lines)
The stack trace of the given exception as a multi-line String.
|
public static String filterStackTrace(String stackTrace, String... packagesToStrip)
public static String stackTraceToString()
public static String stackTraceToString(int lines)
public static String stackTraceToString(Throwable throwable)
public static String stackTraceToString(Throwable throwable, int lines)
public static int getLineNumber(Throwable throwable, String className)
RuntimeException at Foo.java line 42 at Bar.java line 18 at Bar.java line 29and you ask for the line number from Bar, returns 18.
public static int getLineNumber(Throwable throwable, String className, String methodName)
RuntimeException at Foo.java:method0() line 42 at Bar.java:method1() line 96 at Bar.java:method2() line 18 at Bar.java:method2() line 29and you ask for the line number from Bar, method2, returns 18.
public static String getCallingClassName(String... classNamesToSkip)
public static String getMethodName(Throwable throwable, String className)