Skip to content

Passing error information though #167

@KantarBruceAdams

Description

@KantarBruceAdams

Hi,
I wanted to adapt the output from CLI11 to match my local standard, which is Unix style.
So instead of:

The following arguments were not expected: foo bar

I want:

MyProgram: error: unexpected arguments "foo", "bar"

and instead of:

The value Foo is not an allowed value for -Bar

I want:

MyProgram: invalid usage, "Foo" is not an allowed value for option "--Bar"

I thought no problem I can simply catch the exceptions and translate them.
This is not possible as the exception classes such as "ConversionError" construct the message but do not preserve the parameters needed:

ConversionError(std::string member, std::string name)
    : ConversionError("The value " + member + " is not an allowed value for " + name) {}

It would be a simple change to make "member" and "name" member variables of the exception class for this and the other errors.
Would a pull request making this change be accepted (assuming I can find the time)?

Regards,

Bruce.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions