All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nl.hsac.fitnesse.slim.interaction.ExceptionHelper Maven / Gradle / Ivy

There is a newer version: 5.3.17
Show newest version
package nl.hsac.fitnesse.slim.interaction;

import java.lang.reflect.InvocationTargetException;

public class ExceptionHelper {
    private ExceptionHelper() {}

    public static Throwable stripReflectionException(Throwable t) {
        Throwable result = t;
        if (t instanceof InvocationTargetException) {
            InvocationTargetException e = (InvocationTargetException) t;
            if (e.getCause() != null) {
                result = e.getCause();
            } else {
                result = e.getTargetException();
            }
        }
        return result;
    }

    public static InvocationTargetException wrapInReflectionException(Throwable t) {
        InvocationTargetException result;
        if (t instanceof InvocationTargetException) {
            result = (InvocationTargetException) t;
        } else {
            result = new InvocationTargetException(t, t.getMessage());
        }
        return result;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy