[Interest] Args

Igor Mironchik igor.mironchik at gmail.com
Mon May 8 06:48:55 CEST 2017

>>> Using exceptions in arguments parser is something that just cannot be justified.
>> Why not?
> Even in the danger of starting a huge debate about "exceptions vs return error code" here are my thoughts about it:
> Exceptions should just be used for... well, /exceptional/ cases.
> So what would be an "exceptional case" for a command line parser then? Certainly not wrongly provided arguments. Humans tend to misspell words all the time, so that's "the norm": business as usual for a command line parser to validate the input and inform the user appropriately (with a usage help, similar spelled commands etc.). Nothing which cries "exception!" here IMHO.
> The only thing I could think of in a 10 second brainstorming which could be considered "exceptional" is when e.g. "stdin" (or some socket even from which to read commands, but even this would be a bordercase, as it could be considered "normal" that a socket cannot be opened) cannot be opened for reading (which is somewhat a constructed example, as arguments are usually passed as input parameters to main() anyway - but you get the idea).
> The internet is full of articles - and opinions - about when to use exceptions, and when not (and we haven't even touched the topic of "unchecked vs checked exceptions" - at least in the Java camp that's all the rage ;)).

I will not start that holly war about what you said.... :) I just say 
that I will think about more and more user friendly messages on wrong 
user input. I wanted to simplify a life of a developer and a user of 
console application. But developer will be informed about "errors" 
through the exceptions.

This email has been checked for viruses by AVG.

More information about the Interest mailing list