Java Throwable to String getExceptionAsString(Throwable _ex)

Here you can find the source of getExceptionAsString(Throwable _ex)

Description

get Exception As String

License

Open Source License

Declaration

private static String getExceptionAsString(Throwable _ex) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.ByteArrayOutputStream;

import java.io.PrintStream;

public class Main {
    private static String getExceptionAsString(Throwable _ex) {
        if (_ex == null) {
            return null;
        }/* w  w w  .j av  a 2s .c o  m*/
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        if (_ex.getStackTrace() == null) {
            _ex.fillInStackTrace();
        }
        _ex.printStackTrace(new PrintStream(baos));
        return baos.toString();
    }
}

Related

  1. formatThrowableForHtml(Throwable t)
  2. formatThrown(final Throwable thrown)
  3. getDetails(Throwable t)
  4. getErrorInfo(Throwable error)
  5. getErrorMessage(Throwable e)
  6. getExceptionDescription(Throwable e)
  7. getExceptionDetails (final Throwable e)
  8. getExceptionDetails(Throwable throwable)
  9. getExceptionHeadline(Throwable t)