@Test public void throwableToString_with_NestedThrowable() { final RuntimeException exception = new RuntimeException( "X", new IOException( "Y" ) ); final String text = ReplicantUtil.throwableToString( exception ); assertTrue( text.startsWith( "java.lang.RuntimeException: X\n" ) ); assertTrue( text.contains( "\nCaused by: java.io.IOException: Y\n" ) ); }
@Nonnull static String throwableToString( @Nonnull final Throwable throwable ) { final StringBuilder sb = new StringBuilder(); Throwable t = throwable; while ( null != t ) { addCausedByPrefix( sb ); sb.append( t.toString() ); for ( final StackTraceElement element : t.getStackTrace() ) { sb.append( "\n at " ).append( element ); } t = t.getCause(); } return sb.toString(); }
ReplicantUtil { @Nonnull static String throwableToString( @Nonnull final Throwable throwable ) { final StringBuilder sb = new StringBuilder(); Throwable t = throwable; while ( null != t ) { addCausedByPrefix( sb ); sb.append( t.toString() ); for ( final StackTraceElement element : t.getStackTrace() ) { sb.append( "\n at " ).append( element ); } t = t.getCause(); } return sb.toString(); } }
ReplicantUtil { @Nonnull static String throwableToString( @Nonnull final Throwable throwable ) { final StringBuilder sb = new StringBuilder(); Throwable t = throwable; while ( null != t ) { addCausedByPrefix( sb ); sb.append( t.toString() ); for ( final StackTraceElement element : t.getStackTrace() ) { sb.append( "\n at " ).append( element ); } t = t.getCause(); } return sb.toString(); } private  ReplicantUtil(); }
ReplicantUtil { @Nonnull static String throwableToString( @Nonnull final Throwable throwable ) { final StringBuilder sb = new StringBuilder(); Throwable t = throwable; while ( null != t ) { addCausedByPrefix( sb ); sb.append( t.toString() ); for ( final StackTraceElement element : t.getStackTrace() ) { sb.append( "\n at " ).append( element ); } t = t.getCause(); } return sb.toString(); } private  ReplicantUtil();  }
ReplicantUtil { @Nonnull static String throwableToString( @Nonnull final Throwable throwable ) { final StringBuilder sb = new StringBuilder(); Throwable t = throwable; while ( null != t ) { addCausedByPrefix( sb ); sb.append( t.toString() ); for ( final StackTraceElement element : t.getStackTrace() ) { sb.append( "\n at " ).append( element ); } t = t.getCause(); } return sb.toString(); } private  ReplicantUtil();   }