StackOverflowError with StringOperand when trying to print the message of an exception

Issue #6 closed
Simon Brunner created an issue

Description

When using a string operand and an ambiguous syntax, printing the exception message leads to a StackOverflowError. The codesnippet below reproduces this behaviour when executed with no args.

Example

    public static void main(String... args) {
        Term syntax = cases(CliSugar.none("none"),
                            optional(helpFlag()), //ambiguous
                            stringOperand("operand", "description")); //needed for stack overflow to happen
        ArgsParserProperties parser = new ArgsParserProperties()
                .withArgsSyntax(syntax);
        try {
            parser.evalArgs(args);
        } catch (ArgsSyntaxException e) {
            System.out.println(e.toMessage()); //StackOverflowError happens in here
            throw new RuntimeException(e);
        }
    }

Expected behavior

A nice exception message is printed instead of the StackOverflowError.

Comments (1)

  1. Log in to comment