package com.atlassian.bitbucket.test;

public class ThrowableUtils {

    private ThrowableUtils() {
        throw new UnsupportedOperationException(getClass().getName() +
                " is a utility class and should not be instantiated");
    }

    /**
     * Part A of a little compiler trick to throw checked exceptions without declaring them
     */
    public static void throwUnchecked(Throwable e) {
        ThrowableUtils.<RuntimeException>throwAny(e);
    }

    /**
     * Part B of a little compiler trick to throw checked exceptions without declaring them
     */
    @SuppressWarnings("unchecked")
    private static <E extends Throwable> void throwAny(Throwable e) throws E {
        throw (E) e;
    }

}

