Converts a Throwable to a DeleteException. If the Throwable is a
DeleteException, it will be passed through unmodified; otherwise, it will be wrapped
in a new DeleteException.

@param cause the Throwable to convert

@return a DeleteException
770055
public static DeleteException fromThrowable(Throwable cause) {
    return (cause instanceof DeleteException)
                   ? (DeleteException) cause
                   : new DeleteException(cause);
  }
936125
public static List<Throwable> getCausalChain(final Throwable throwable) {
		if (throwable == null) {
			throw new NullPointerException("Throwable is null");
		}
		
		List<Throwable> causes = new ArrayList<Throwable>();
		causes.add(throwable);
		
		Throwable cause = throwable.getCause();
		
		while ((cause != null) && (!causes.contains(cause))) {
			causes.add(cause);
			cause = cause.getCause();
		}
		
		return causes;
	}
875769
public void incrementExceptionCount(Throwable throwable) {

        if (throwable instanceof ServiceUnavailableException) {
            serviceUnavailableExceptionCounter.incrementAndGet();
        } else if (containsThrowableOfType(throwable, communicationExceptionsTypes)) {
            communicationExceptionCounter.incrementAndGet();
        } else if (containsThrowableOfType(throwable, businessExceptionsTypes)) {
            businessExceptionCounter.incrementAndGet();
        } else {
            otherExceptionCounter.incrementAndGet();
        }
    }
841605
private ResultAction getFailedResultAction(Throwable cause) {
        if (currentStage == Stage.MODEL || cancelled || isRollbackOnRuntimeFailure() || isRollbackOnly()
                || (cause != null && !(cause instanceof OperationFailedException))) {
            return ResultAction.ROLLBACK;
        }
        return ResultAction.KEEP;
    }
261102
static MojoExecutionException unwrapTaskException(
            final Exception exception,
            @Nullable final Throwable cause) {
        if (cause instanceof CompletionException || cause instanceof ExecutionException) {
            return unwrapTaskException((Exception) cause, cause.getCause());
        } else if (cause != null) {
            return new MojoExecutionException("Class processing failed", cause);
        } else {
            return new MojoExecutionException("Unknown class processing exception", exception);
        }
    }
819057
public static Throwable unwrap(Throwable wrapped) {
		Throwable unwrapped = wrapped;
		while (true) {
			if (unwrapped instanceof InvocationTargetException) {
				unwrapped = ((InvocationTargetException) unwrapped).getTargetException();
			} else if (unwrapped instanceof UndeclaredThrowableException) {
				unwrapped = ((UndeclaredThrowableException) unwrapped).getUndeclaredThrowable();
			} else {
				return unwrapped;
			}
		}
	}
290677
public List<Throwable> getCauses(Throwable t)
    {
        List<Throwable> causes = new LinkedList<Throwable>();
        Throwable next = t;
        while (next.getCause() != null)
        {
            next = next.getCause();
            causes.add(next);
        }
        return causes;
    }
994591
public static Throwable stripException(Throwable throwableToStrip, Class<? extends Throwable> typeToStrip) {
		while (typeToStrip.isAssignableFrom(throwableToStrip.getClass()) && throwableToStrip.getCause() != null) {
			throwableToStrip = throwableToStrip.getCause();
		}

		return throwableToStrip;
	}
982504
public boolean setException(TBase<?, ?> result, Throwable cause) {
        final Class<?> causeType = cause.getClass();
        for (Entry<Class<Throwable>, TFieldIdEnum> e : exceptionFields.entrySet()) {
            if (e.getKey().isAssignableFrom(causeType)) {
                ThriftFieldAccess.set(result, e.getValue(), cause);
                return true;
            }
        }
        return false;
    }
299471
public static String formatException(Throwable exception) {
		StringBuilder buffer = new StringBuilder();

		formatException(exception, buffer);

		return buffer.toString();
	}
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));
        }
    }
977800
@SuppressWarnings("deprecation")
    protected Throwable getNestedException(Throwable t) {
        Throwable root = t;
        for (;;) {
            if (root instanceof RemoteException) {
                RemoteException re = (RemoteException) root;
                if (re.detail == null)
                    break;
                root = re.detail;
            } else if (root instanceof NamingException) {
                NamingException ne = (NamingException) root;
                if (ne.getRootCause() == null)
                    break;
                root = ne.getRootCause();
            } else if (root instanceof com.ibm.ws.exception.WsNestedException) { //d121522
                com.ibm.ws.exception.WsNestedException ne = (com.ibm.ws.exception.WsNestedException) root;
                if (ne.getCause() == null)
                    break;
                root = ne.getCause();
            } else {
                break;
            }
        }
        return root;
    }
120084
@Nonnull
    LessException createException( Throwable cause ) {
        LessException lessEx = cause.getClass() == LessException.class ? (LessException)cause : new LessException( cause );
        lessEx.addPosition( filename, line, column );
        return lessEx;
    }
158892
public MethodHandle throwException() {
        if (type().parameterCount() != 1 || !Throwable.class.isAssignableFrom(type().parameterType(0))) {
            throw new InvalidTransformException("incoming signature must have one Throwable type as its sole argument: " + type());
        }
        return invoke(MethodHandles.throwException(type().returnType(), type().parameterType(0).asSubclass(Throwable.class)));
    }
1351802
public static <T extends Throwable> T convertFromOrSuppressedThrowable(Throwable throwable, Class<T> exceptionClass) {
		return convertFromOrSuppressedThrowable(throwable, exceptionClass, true);
	}
998094
public void sendException(Throwable throwable) {
        EventBuilder eventBuilder = new EventBuilder().withMessage(throwable.getMessage())
            .withLevel(Event.Level.ERROR)
            .withSentryInterface(new ExceptionInterface(throwable));
        sendEvent(eventBuilder);
    }
766114
public static boolean causedBy( final Throwable                     ex,
                                    final Class<? extends Throwable>    exceptionClass )
    {
        Throwable    cause = ex;

        while( cause != null && ! exceptionClass.isInstance( cause ) )
        {
            cause = cause.getCause();
        }

        return ( cause == null ) ? false : true;
    }