Example usage for com.google.common.util.concurrent UncheckedExecutionException setStackTrace

List of usage examples for com.google.common.util.concurrent UncheckedExecutionException setStackTrace

Introduction

In this page you can find the example usage for com.google.common.util.concurrent UncheckedExecutionException setStackTrace.

Prototype

public void setStackTrace(StackTraceElement[] stackTrace) 

Source Link

Document

Sets the stack trace elements that will be returned by #getStackTrace() and printed by #printStackTrace() and related methods.

Usage

From source file:org.jclouds.rest.internal.BlockOnFuture.java

private static RuntimeException propagateCause(Exception e) {
    Throwable cause = e.getCause();
    if (cause == null) {
        UncheckedExecutionException unchecked = new UncheckedExecutionException(e.getMessage()) {
            private static final long serialVersionUID = 1L;
        };//w w w . j  a v a2s.  c om
        unchecked.setStackTrace(e.getStackTrace());
        throw unchecked;
    }
    StackTraceElement[] combined = concat(cause.getStackTrace(), e.getStackTrace(), StackTraceElement.class);
    cause.setStackTrace(combined);
    if (cause instanceof RuntimeException) {
        throw (RuntimeException) cause;
    }
    if (cause instanceof Error) {
        throw (Error) cause;
    }
    // The cause is a weird kind of Throwable, so throw the outer exception.
    throw new RuntimeException(e);
}