commandlineparser / commandline

The best C# command line parser that brings standardized *nix getopt style, for .NET. Includes F# support
MIT License
4.46k stars 473 forks source link

Bad format doesn't contain a lot of info #921

Open labsin opened 4 months ago

labsin commented 4 months ago

Describe the bug If a conversion in the constructor of a datatype throws an error, only a very generic error is available:

Option 'some option' is defined with a bad format.

To Reproduce

Expected behavior There are some options:

  1. Add the used parameter to the BadFormatConversionError type so the bad formatted input string can be shown in the custom help callback.
  2. Catch TargetInvocationException and add the inner exception to the BadFormatConversionError
  3. Show a message with the message of the exception, especially when the exception is an ArgumentException. It would then read something like 'Option 'i, input' is defined with "Invalid;Path" which is a bad format: Illegal characters in path.'
labsin commented 4 months ago

Relates to https://github.com/commandlineparser/commandline/issues/113

labsin commented 4 months ago

BTW, the initial problem was https://github.com/commandlineparser/commandline/issues/226, which I had to debug to see the actual thing that went wrong.