Java Throwable to String getExceptionDetails(Throwable throwable)

Here you can find the source of getExceptionDetails(Throwable throwable)

Description

Get exception information as a string.

License

Open Source License

Parameter

Parameter Description
throwable a Throwable object.

Return

exception information as a string.

Declaration

public final static String getExceptionDetails(Throwable throwable) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 *
 * Copyright (c) 2002, 2008 IBM Corporation, Beacon Information Technology Inc. and others.
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*from   ww w .  j ava 2 s  .c  o m*/
 *   IBM      - Initial API and implementation
 *   BeaconIT - Initial API and implementation
 *******************************************************************************/

import java.io.PrintWriter;
import java.io.StringWriter;

public class Main {
    /** 
     * Get exception information as a string.
     * @param throwable  a Throwable object.
     * @return exception information as a string.
     */
    public final static String getExceptionDetails(Throwable throwable) {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);

        pw.println("Exception: ");
        throwable.printStackTrace(pw);

        return sw.toString();
    }
}

Related

  1. getErrorInfo(Throwable error)
  2. getErrorMessage(Throwable e)
  3. getExceptionAsString(Throwable _ex)
  4. getExceptionDescription(Throwable e)
  5. getExceptionDetails (final Throwable e)
  6. getExceptionHeadline(Throwable t)
  7. getExceptionPrintout(Throwable aThrowable)
  8. getExceptionStack(final Throwable e)
  9. getExceptionStack(Throwable e)