Code example for InvocationTargetException

Methods: getCause

    public Closure createClosure(final Method method, final Object o, final Object... args) {
        try { 
            Object closureObj = method.invoke(o, args); // creates instance of an anonymous class
            return createClosure(method.getName(), closureObj);
        } catch (InvocationTargetException e) {
            throw Throwables.propagate(e.getCause());
        } catch (Exception e) {
            throw Throwables.propagate(e);
     * Creates closure. 
     * @param rootMethodName the name of external method within which closure is created. 
     * @param closureObj     the instance of specific anonymous class 
     * @return new {@link Closure} instance 
     * @throws Exception 
    Closure createClosure(String rootMethodName, final Object closureObj) throws Exception {
Experience pair programming with AI  Get Codota for Java