Search in sources :

Example 1 with InvalidArgumentException

use of net.robinfriedli.aiode.exceptions.InvalidArgumentException in project aiode by robinfriedli.

the class ArgumentBuildingMode method terminate.

@Override
public void terminate() {
    try {
        if (argumentBuilder.length() == 0) {
            throw new InvalidArgumentException("Missing argument identifier");
        }
        ArgumentController argumentController = command.getArgumentController();
        String argument = argumentBuilder.toString().trim();
        String argumentValue = argumentValueBuilder.toString().trim();
        argumentController.setArgument(argument, argumentValue);
        commandParser.fireOnArgumentParsed(argument, argumentValue);
    } catch (UserException e) {
        throw new CommandParseException(e.getMessage(), command.getCommandBody(), e, conceptionIndex);
    }
}
Also used : CommandParseException(net.robinfriedli.aiode.exceptions.CommandParseException) InvalidArgumentException(net.robinfriedli.aiode.exceptions.InvalidArgumentException) ArgumentController(net.robinfriedli.aiode.command.argument.ArgumentController) UserException(net.robinfriedli.aiode.exceptions.UserException)

Aggregations

ArgumentController (net.robinfriedli.aiode.command.argument.ArgumentController)1 CommandParseException (net.robinfriedli.aiode.exceptions.CommandParseException)1 InvalidArgumentException (net.robinfriedli.aiode.exceptions.InvalidArgumentException)1 UserException (net.robinfriedli.aiode.exceptions.UserException)1