Here you can find the source of exceptionToString(final Throwable throwable)
public static String exceptionToString(final Throwable throwable)
//package com.java2s; //License from project: Apache License public class Main { public static String exceptionToString(final Throwable throwable) { StringBuilder result = new StringBuilder(); Throwable cause = throwable; while (cause != null) { if (result.length() == 0) { result.append("\nException in thread."); } else { result.append("\nCaused by: "); }/*w ww.ja va2 s . c o m*/ result.append(cause.getClass().getCanonicalName()).append(": ").append(cause.getMessage()); for (final StackTraceElement traceElement : cause.getStackTrace()) { result.append("\n\tat ").append(traceElement.toString()); } cause = cause.getCause(); } return result.toString(); } }