You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "David Goodenough (JIRA)" <ji...@apache.org> on 2015/05/02 10:24:06 UTC
[jira] [Commented] (CLI-249) Message for an illegal character in an
option should contain more information
[ https://issues.apache.org/jira/browse/CLI-249?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14525124#comment-14525124 ]
David Goodenough commented on CLI-249:
--------------------------------------
I am not sure I am the best person to do this. I am a user of code that uses this code. You really need input from those that write that latter code.
However if I were doing it I would look at one of two mechanisms. Either I would add a parameter which is a simple string and would add it to the end of the message, so the caller could might pass in the whole string that is being parsed if it is a command line parse, or a file name and line number if it is a file parse. Both of these would give context to the error message.
As an alternative if you are able to require Java 8(+) then you could pass in a lambda which would get called to return this extra string - that way if we are thinking performance the error string is only created when needed.
> 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)