Here you can find the source of dumpThrowable(Throwable e)
Parameter | Description |
---|---|
e | the throwable. |
public static String dumpThrowable(Throwable e)
//package com.java2s; /*/*from w w w. j av a2 s .c o m*/ * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * * Initial Contributors: * Nokia Corporation - initial contribution. * * Contributors: * * Description: * */ import java.io.PrintWriter; import java.io.StringWriter; public class Main { /** * Extracts the stack trace from the throwable to string. If the throwable * has a cause, the cause will be dumped instead. * * @param e the throwable. * @return the stack trace in text format. */ public static String dumpThrowable(Throwable e) { if (e == null) { return null; } if (e.getCause() != null) { e = e.getCause(); } StringWriter writer = new StringWriter(); e.printStackTrace(new PrintWriter(writer)); return writer.toString(); } }