Package org.fest.util
Class Throwables
- java.lang.Object
-
- org.fest.util.Throwables
-
public final class Throwables extends java.lang.Object
Utility methods related to
s.Throwable
- Author:
- Alex Ruiz
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
appendStackTraceInCurentThreadToThrowable(java.lang.Throwable t, java.lang.String methodToStartFrom)
Appends the stack trace of the current thread to the one in the given
.Throwable
static void
removeFestRelatedElementsFromStackTrace(java.lang.Throwable throwable)
Removes the FEST-related elements from the
stack trace that have little value for end user.Throwable
-
-
-
Method Detail
-
appendStackTraceInCurentThreadToThrowable
public static void appendStackTraceInCurentThreadToThrowable(java.lang.Throwable t, java.lang.String methodToStartFrom)
Appends the stack trace of the current thread to the one in the given
.Throwable
- Parameters:
t
- the givenThrowable
.methodToStartFrom
- the name of the method used as the starting point of the current thread's stack trace.
-
removeFestRelatedElementsFromStackTrace
public static void removeFestRelatedElementsFromStackTrace(java.lang.Throwable throwable)
Removes the FEST-related elements from the
stack trace that have little value for end user. Therefore, instead of seeing this:Throwable
org.junit.ComparisonFailure: expected:<'[Ronaldo]'> but was:<'[Messi]'> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:501) at org.fest.assertions.error.ConstructorInvoker.newInstance(ConstructorInvoker.java:34) at org.fest.assertions.error.ShouldBeEqual.newComparisonFailure(ShouldBeEqual.java:111) at org.fest.assertions.error.ShouldBeEqual.comparisonFailure(ShouldBeEqual.java:103) at org.fest.assertions.error.ShouldBeEqual.newAssertionError(ShouldBeEqual.java:81) at org.fest.assertions.internal.Failures.failure(Failures.java:76) at org.fest.assertions.internal.Objects.assertEqual(Objects.java:116) at org.fest.assertions.api.AbstractAssert.isEqualTo(AbstractAssert.java:74) at examples.StackTraceFilterExample.main(StackTraceFilterExample.java:13)
We get this:org.junit.ComparisonFailure: expected:<'[Ronaldo]'> but was:<'[Messi]'> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at examples.StackTraceFilterExample.main(StackTraceFilterExample.java:20)
- Parameters:
throwable
- theThrowable
to filter stack trace.
-
-