private String getStackTrace ( final Throwable exception ) { if ( exception != null ) { StringBuilder sb = new StringBuilder ( ) ; StackTraceElement [ ] stackTrace = exception . getStackTrace ( ) ; for ( StackTraceElement element : stackTrace ) { sb . append ( element . toString ( ) ) ; sb . append ( ' ' ) ; } if ( exception . getCause ( ) != null ) { StackTraceElement [ ] stackTraceCause = exception . getCause ( ) . getStackTrace ( ) ; for ( StackTraceElement element : stackTraceCause ) { sb . append ( element . toString ( ) ) ; sb . append ( ' ' ) ; } } return sb . toString ( ) ; } return null ; }
Gets stacktrace as a String .