@Test public void testToString() throws Exception { Assert.assertEquals( "java.lang.Exception: level-1" + NL + " --- Caused by java.lang.IllegalStateException: level-2" + NL + " --- Caused by java.lang.NullPointerException: level-3", new ExceptionTransforms().toString( new Exception("level-1", new IllegalStateException("level-2", new NullPointerException("level-3"))))); }
@Transformer public String toString(Throwable t) { Throwable cause = t; StringBuilder result = new StringBuilder(cause.getClass().getName() + ": " + cause.getMessage()); while ((cause = cause.getCause()) != null) { result.append(NL + " --- Caused by " + cause.getClass().getName() + ": " + cause.getMessage()); } return result.toString(); }
ExceptionTransforms { @Transformer public String toString(Throwable t) { Throwable cause = t; StringBuilder result = new StringBuilder(cause.getClass().getName() + ": " + cause.getMessage()); while ((cause = cause.getCause()) != null) { result.append(NL + " --- Caused by " + cause.getClass().getName() + ": " + cause.getMessage()); } return result.toString(); } }
ExceptionTransforms { @Transformer public String toString(Throwable t) { Throwable cause = t; StringBuilder result = new StringBuilder(cause.getClass().getName() + ": " + cause.getMessage()); while ((cause = cause.getCause()) != null) { result.append(NL + " --- Caused by " + cause.getClass().getName() + ": " + cause.getMessage()); } return result.toString(); }  }
ExceptionTransforms { @Transformer public String toString(Throwable t) { Throwable cause = t; StringBuilder result = new StringBuilder(cause.getClass().getName() + ": " + cause.getMessage()); while ((cause = cause.getCause()) != null) { result.append(NL + " --- Caused by " + cause.getClass().getName() + ": " + cause.getMessage()); } return result.toString(); }  @Transformer String toString(Throwable t); }
ExceptionTransforms { @Transformer public String toString(Throwable t) { Throwable cause = t; StringBuilder result = new StringBuilder(cause.getClass().getName() + ": " + cause.getMessage()); while ((cause = cause.getCause()) != null) { result.append(NL + " --- Caused by " + cause.getClass().getName() + ": " + cause.getMessage()); } return result.toString(); }  @Transformer String toString(Throwable t); static final ExceptionTransforms TRANSFORMER; }