Example usage for java.lang Throwable setCause

List of usage examples for java.lang Throwable setCause

Introduction

In this page you can find the example usage for java.lang Throwable setCause.

Prototype

final void setCause(Throwable t) 

Source Link

Usage

From source file:org.eclipse.epp.internal.logging.aeri.ui.model.Reports.java

public static Throwable newThrowable(java.lang.Throwable throwable) {
    Throwable mThrowable = factory.createThrowable();
    mThrowable.setMessage(throwable.getMessage());
    mThrowable.setClassName(throwable.getClass().getName());
    List<StackTraceElement> mStackTrace = mThrowable.getStackTrace();
    for (java.lang.StackTraceElement stackTraceElement : throwable.getStackTrace()) {
        StackTraceElement mStackTraceElement = factory.createStackTraceElement();
        mStackTraceElement.setFileName(stackTraceElement.getFileName());
        mStackTraceElement.setClassName(ensureNotBlank(stackTraceElement.getClassName(), throwable));
        mStackTraceElement.setMethodName(ensureNotBlank(stackTraceElement.getMethodName(), throwable));
        mStackTraceElement.setLineNumber(stackTraceElement.getLineNumber());
        mStackTraceElement.setNative(stackTraceElement.isNativeMethod());
        mStackTrace.add(mStackTraceElement);
    }/*from w  ww. j a  v a2  s.com*/
    java.lang.Throwable cause = throwable.getCause();
    if (cause != null) {
        if (cause == throwable) {
            log(WARN_CYCLIC_EXCEPTION, cause.toString());
            return mThrowable;
        }
        mThrowable.setCause(newThrowable(cause));
    }
    return mThrowable;
}