Here you can find the source of exceptionToString(Throwable e)
public static String exceptionToString(Throwable e)
//package com.java2s; /*//from ww w . j a v a 2s .c o m * ZAL - The abstraction layer for Zimbra. * Copyright (C) 2014 ZeXtras S.r.l. * * This file is part of ZAL. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, version 2 of * the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ZAL. If not, see <http://www.gnu.org/licenses/>. */ public class Main { public static String exceptionToString(Throwable e) { StringBuilder sb = new StringBuilder(128); StackTraceElement elements[] = e.getStackTrace(); sb.append(e.toString()); sb.append("\n"); for (int n = 0; n < elements.length; ++n) { sb.append(" at "); sb.append(elements[n].getClassName()); sb.append("."); sb.append(elements[n].getMethodName()); sb.append(" ( "); sb.append(elements[n].getFileName()); sb.append(":"); sb.append(elements[n].getLineNumber()); sb.append(" )"); if (elements[n].isNativeMethod()) { sb.append(" [native]"); } sb.append("\n"); } Throwable cause = e.getCause(); if (cause != null) { sb.append("Caused by: "); sb.append(exceptionToString(cause)); } return sb.toString(); } }