protected static String printException ( final Throwable throwable ) { if ( null == throwable ) { return null ; } final ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; final PrintStream printStream = new PrintStream ( baos ) ; throwable . printStackTrace ( printStream ) ; String exceptionStr = "" ; try { exceptionStr = baos . toString ( "UTF-8" ) ; } catch ( Exception ex ) { exceptionStr = "Unavailable" ; } finally { closeStream ( printStream ) ; closeStream ( baos ) ; } return exceptionStr ; }
prints a exception into a string