Java Throwable to String getExceptionText(Throwable e)

Here you can find the source of getExceptionText(Throwable e)

Description

get Exception Text

License

Open Source License

Declaration

public static String getExceptionText(Throwable e) 

Method Source Code

//package com.java2s;
/**// w w w  . j  a va  2  s  .  com
 * Util.java
 * @author John Green
 * 27-Oct-2002
 * www.joanju.com
 * 
 * Copyright (c) 2002 Joanju Limited.
 * 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
 * 
 */

import java.io.*;

public class Main {
    public static String getExceptionText(Throwable e) {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        pw.print(e.toString() + "\n" + e.getMessage() + "\n");
        e.printStackTrace(pw);
        return sw.toString();
    }
}

Related

  1. getExceptionStackTrace(Throwable exception)
  2. getExceptionStackTrace(Throwable exception)
  3. getExceptionString(Throwable e)
  4. getExceptionString(Throwable t)
  5. getExceptionString(Throwable throwable)
  6. getExceptionTrace(Throwable e)
  7. getStackTrace (final Throwable e)
  8. getStackTrace(@Nonnull final Throwable throwable)
  9. getStackTrace(final Throwable aThrowable)