private static String extractErrorSummary(Throwable e){
  StringBuilder errorMessageBuilder=new StringBuilder();
  Throwable cause=e;
  errorMessageBuilder.append(cause.getLocalizedMessage());
  while (cause != null) {
    StackTraceElement[] stackTraceElements=cause.getStackTrace();
    errorMessageBuilder.append(stackTraceElements.length > 0 ? "\n caused by: " + stackTraceElements[0] : "");
    cause=cause.getCause();
  }
  return errorMessageBuilder.toString();
}

private static String extractErrorSummary ( Throwable e ) { StringBuilder errorMessageBuilder = new StringBuilder ( ) ; Throwable cause = e ; errorMessageBuilder . append ( cause . getLocalizedMessage ( ) ) ; while ( cause != null ) { StackTraceElement [ ] stackTraceElements = cause . getStackTrace ( ) ; errorMessageBuilder . append ( stackTraceElements . length > 0 ? "\n caused by: " + stackTraceElements [ 0 ] : "" ) ; cause = cause . getCause ( ) ; } return errorMessageBuilder . toString ( ) ; }
extract the meaningful part of a stack trace : a . the causes in the stack trace hierarchy b . the top exception for each cause
