Unwraps a throwable.

@param throwable the throwable
@return the unwrapped throwable, or the original throwable
765232
public static @NonNull Throwable unwrap(final @NonNull Throwable throwable) {
    if(throwable instanceof InvocationTargetException) {
      final /* @Nullable */ Throwable cause = throwable.getCause();
      if(cause != null) {
        return cause;
      }
    }
    return throwable;
  }
526816
public static Throwable unwrap(@Nullable Throwable t) {
		if (t instanceof UncheckedException || t instanceof java.util.concurrent.ExecutionException
				|| t instanceof java.lang.reflect.InvocationTargetException
				|| t instanceof UndeclaredThrowableException) {
			return t.getCause();
		}

		return t;
	}
249247
public Throwable getThrowable(Object[] args) {
    Throwable rv = null;
    if (args.length > 0) {
      if (args[args.length - 1] instanceof Throwable) {
        rv = (Throwable) args[args.length - 1];
      }
    }
    return rv;
  }
410224
public static Throwable unwrapCause(Throwable e) {
        if (e instanceof CommandActionExecutionException) {
            return e.getCause();
        }
        if (e instanceof HystrixBadRequestException) {
            return e.getCause();
        }
        return e;
    }
455252
public static RuntimeException wrap(Throwable e) {
        if (e instanceof RuntimeException) {
            return (RuntimeException) e;
        }
        return new RuntimeException(e);
    }
949491
private static AlgorithmException wrapException(Throwable throwable) {
        if(throwable == null) {
            return null;
        } else if(throwable instanceof AlgorithmException) {
            return (AlgorithmException) throwable;
        } else {
            return new AlgorithmException(throwable.getMessage(), wrapException(throwable.getCause()), wrapStackTrace(throwable));
        }
    }
52509
protected Map<String, Object> unwrap(Map<String, Object> namedParameters) {
		Map<String, Object> unwrapped = new HashMap<String, Object>( namedParameters.size() );

		for ( Entry<String, Object> entry : namedParameters.entrySet() ) {
			Object value = entry.getValue();
			unwrapped.put( entry.getKey(), value instanceof TypedValue ? ( (TypedValue) value ).getValue() : value );
		}

		return unwrapped;
	}
599644
public static <T> CompletableFuture<T> getFailedFuture(Throwable throwable) {
		CompletableFuture<T> failedAttempt = new CompletableFuture<>();
		failedAttempt.completeExceptionally(throwable);
		return failedAttempt;
	}
457989
private Throwable wrapCancellationException(Throwable u) {
        Throwable wrappedException = null;
        if (u != null) {
            wrappedException = Exceptions.unwrap(u);
            if (wrappedException instanceof CancellationException) {
                wrappedException = new ReadCancellationException(wrappedException);
            }
        }
        return wrappedException;
    }
425728
public static RuntimeException wrap(Throwable throwable) {
        RuntimeException result;
        if (throwable instanceof RuntimeException) {
            result = (RuntimeException) throwable;
        } else {
            result = new RuntimeException(throwable.getClass().getSimpleName(), throwable);
        }
        return result;
    }
978797
static Throwable unwrapException(Throwable wrapped, StringBuilder outAction) {
        Throwable unwrapped = wrapped;

        while ((unwrapped instanceof ExecutionException) || (unwrapped instanceof CompletionException)
                || (unwrapped instanceof ExceptionWithAction)) {
            if ((unwrapped instanceof ExceptionWithAction) && (outAction != null)) {
                // Save the action string from an ExceptionWithAction, if desired.
                outAction.append(((ExceptionWithAction) unwrapped).getAction());
            }

            if ((unwrapped.getCause() != null) && (unwrapped.getCause() instanceof Exception)) {
                unwrapped = unwrapped.getCause();
            } else {
                break;
            }
        }

        return unwrapped;
    }
565568
public static String[] getThrowableStrRep(Throwable throwable) {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        throwable.printStackTrace(pw);
        pw.flush();
        LineNumberReader reader = new LineNumberReader(new StringReader(sw.toString()));
        ArrayList<String> lines = new ArrayList<>();
        try {
            String line = reader.readLine();
            while(line != null) {
                lines.add(line);
                line = reader.readLine();
            }
        } catch(IOException ex) {
            lines.add(ex.toString());
        }
        String[] rep = new String[lines.size()];
        lines.toArray(rep);
        return rep;
    }
1351802
public static <T extends Throwable> T convertFromOrSuppressedThrowable(Throwable throwable, Class<T> exceptionClass) {
		return convertFromOrSuppressedThrowable(throwable, exceptionClass, true);
	}
1340583
public static RuntimeException propagate(Throwable throwable) {
    final Throwable t = Preconditions.checkNotNull(throwable, "throwable");
    if (t instanceof Error) {
      throw (Error) t;
    }
    if (t instanceof RuntimeException) {
      throw (RuntimeException) t;
    }

    throw new RuntimeException(t);
  }
278319
public static <T> ResultQueueEntry<T> fromThrowable(Throwable throwable) {
    Preconditions.checkArgument(throwable != null, "Throwable may not be null");
    return new ExceptionResultQueueEntry<T>(throwable);
  }
729329
@Override
	public <T> T unwrap(final Class<T> iface) throws SQLException {
		if (iface != null && this.getClass().isAssignableFrom(iface)) {
			return iface.cast(this);
		}

		return wrapped.unwrap(iface);
	}
1188037
public <T extends Throwable> T throwing(T throwable) {
        if (instanceofLAL) {
            ((LocationAwareLogger) logger).log(THROWING_MARKER, FQCN, LocationAwareLogger.ERROR_INT, "throwing", null, throwable);
        }
        return throwable;
    }