[m-rev.] for review / comment: structured errors for getopt
Paul Bone
paul at bone.id.au
Wed Apr 2 12:42:36 AEDT 2014
On Wed, Apr 02, 2014 at 11:49:07AM +1100, Julien Fischer wrote:
>
>>> + ; requires_argument(OptionType, string)
>>> + % The option requires an argument but it occurred on the command
>>> + % line without one.
>>> +
>>> + ; does_not_allow_argument(OptionType, string, string)
>>> + % The option does not allow an argument but it was provided with
>>> + % one on the command line.
>>> + % The third argument gives the contents of the argument position
>>> + % on the command line.
>>> +
>>> + ; cannot_negate(OptionType, string)
>>> + % The option cannot be negated but its negated form appeared on
>>> + % the command line.
>>> +
>>> + ; special_handler_failed(OptionType, string)
>>> + % The special option handler predicate for the option failed.
>>> +
>>> + ; special_handler_missing(OptionType, string)
>>> + % A special option handler predicate was not provided for the option.
>>> +
>>> + ; special_handler_error(OptionType, string, string)
>>> + % The special option handler predicate for the option returned an
>>> + % error.
>>> + % The third argument is a string describing the error.
>>> +
>>> + ; requires_numeric_argument(OptionType, string, string)
>>> + % The option requires a numeric argument but it occurred on the
>>> + % command line with a non-numeric argument.
>>> + % The third argument gives the argument as it appeared on
>>> the + % command line.
>>> +
>>> + ; file_special_cannot_open(OptionType, string, string, io.error)
>>> + % The option is a file_special option whose argument is the file
>>> + % named by the third argument.
>>> + % Attempting to open this file resulted in the I/O error given
>>> + % by the fourth argument.
>>> +
>>> + ; file_special_cannot_read(OptionType, string, string, io.error)
>>> + % The option is a file_special option whose argument is the file
>>> + % named by the third argument.
>>> + % Attempting to read from this file resulted in the I/O error given
>>> + % by the fourth argument.
>>> +
>>> + ; file_special_contains_non_option_args(OptionType, string, string).
>>> + % The option is a file_special option whose argument is the file
>>> + % named by the third argument. This file contained some non-option
>>> + % arguments.
>>
>> This isn't a strong opinion, but it may be reasonable to fold these three
>> constructors together, and then either in the 3rd argument or in a new
>> argument specify at what stage reading the file failed.
>
> I thought about that, but have look at the revised diff I posted the
> other day addressing Peter Wang's comments.
>
I agree, factoring out the first two parameters has helped. I think it's
now less of a problem to fold these three things together and it's probably
not worth while doing so.
Thanks.
--
Paul Bone
More information about the reviews
mailing list