@ Override public void printStackTrace ( PrintWriter p ) { if ( wrapped == null ) { p . println ( "none" ) ; } else { StackTraceElement [ ] stackElements = getStackTraceEliminatingDuplicateFrames ( ) ; // format and print p . println ( wrapped ) ; for ( int i = 0 ; i < stackElements . length ; i ++ ) { StackTraceElement stackTraceElement = stackElements [ i ] ; final String toString = printStackTraceElement ( stackTraceElement ) ; p . println ( "\t" + toString ) ; } TruncatableThrowable cause = getCause ( ) ; // We know the cause will be truncatable, so not much extra work to do here // There's a super-class method we could call, but it's private :( if ( cause != null ) { // Non-internationalised string in what we're trying to imitate if ( cause . isIntermediateCausesStripped ( ) ) { p . print ( "Caused by (repeated) ... : " ) ; } else { p . print ( CAUSED_BY ) ; } cause . printStackTrace ( p ) ; } } }
This method will print a trimmed stack trace to stderr .