Examples of VerbException


Examples of ar.com.dgarcia.java_verbs.api.VerbException

    @Override
    public Verb named(String functionName) {
        Verb verb = verbs.get(functionName);
        if(verb == null){
            throw new VerbException("The requested verb["+functionName+"] does not exists");
        }
        return verb;
    }
View Full Code Here

Examples of ar.com.dgarcia.java_verbs.api.VerbException

    @Override
    public <T> T apply(Object... args) throws VerbException {
        int currentArgCount = (args == null)? 0 : args.length;
        int minimumArgCount = verbDefinition.getMinimumArgCount();
        if(currentArgCount < minimumArgCount){
            throw new VerbException("Verb["+name+"] expected at least "+ minimumArgCount + " arguments but was invoked with "+currentArgCount+": " + Arrays.toString(args));
        }

        int maximumArgCount = verbDefinition.getMaximumArgCount();
        if(currentArgCount > maximumArgCount){
            throw new VerbException("Verb["+name+"] expected at most "+ maximumArgCount + " arguments but was invoked with "+currentArgCount+": " + Arrays.toString(args));
        }

        try {
            return verbDefinition.apply(args);
        } catch (ClassCastException e) {
            throw new VerbException("Verb["+name+"] failed with ClassCastException. Do argument values match expected types? "+e.getMessage()+ ". Args: " + Arrays.toString(args));
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.