[
https://issues.apache.org/jira/browse/CLI-249?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14521243#comment-14521243
]
David Goodenough commented on CLI-249:
--------------------------------------
When I originally looked at this there were two messages, and I must have
looked at an old version as the second (multi character) version did not put in
the whole message. And yes the exception will gain nothing by repeating the
offending character.
However the point remains, that the message contains almost no information that
is useful to the user of any packages using this code in working out what needs
fixing. Now it could be argued that actually the caller should trap this error
and put in some more context, but at a minimum this should be documented, and
in real life is not going to happen. Perhaps the current API should be
deprecated and a new method added that required a string providing that context
be supplied - but that would cause outcry in the callers as they would have the
change all their code.
The bottom line is that the current except is really not useful to its likely
audience and somehow this needs fixing.
> Message for an illegal character in an option should contain more information
> -----------------------------------------------------------------------------
>
> Key: CLI-249
> URL: https://issues.apache.org/jira/browse/CLI-249
> Project: Commons CLI
> Issue Type: Improvement
> Components: CLI-1.x
> Reporter: David Goodenough
> Fix For: 1.3
>
>
> Currently the code in org.apache.commons.cli.OptionValidator generates an
> IllegalArgumentException which contains the message:-
> "illegal option value '" + ch + "'"
> This is generated in two places, one for single character options and one for
> multi character options.
> However this does not tell the caller which option it is contains this
> character, which makes debugging the error without the source (i.e most
> users) extremely difficult.
> Would it not be possible to change the message to:-
> "illegal option '" + opt + "' value '" + ch + "'"
> which would then at least identify the offending option.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)