-
Notifications
You must be signed in to change notification settings - Fork 0
Understanding exceptions
Exceptions thrown by the library fall into one of the two following categories: parse exceptions and execution exception.
Both exceptions will provide detail about the error by checking the OperationMessages property.
This exception is thrown when the configuration of available commands is invalid. These errors do not depend on the arguments recieved, simply based on discovery of available commands and parameters. They require code changes by the developper to fix.
When loading the code, the library performs the following check, and will raise an error in invalid check:
- Scan all methods in the types specified.
- Ensure there is at least one command.
- Ensure there is at most one default command.
- Ensure no command name have spaces in them.
- Ensure no command are reserved keywords (by default:
--help,-h,?). - Ensure all commands have distinct names.
- Ensure all custom validation rules are valid. See Applying custom rules when parsing commands
- Evaluate command parameters.
- Ensure all parameters have distinct names.
- Ensure no parameters have spaces space in them.
- Ensure no parameters are reserved keywords (by default:
--help,-h,?).
This exception is thrown when validating input arguments (from user) and executing commands. Most cases of invalid arguments will simply print the help on how to use your application, but some cases can throw errors.
- Invalid type is recived (command line argument is converted from
stringto the type specified in the method usingConvert.ChangeType()). - Can not find a public non-empty constructor (in case command is not static).
- Any exceptions raised in your logic.
I recommand leaving method parameters as string and performing the cast yourself.
Need more information or have an idea? Do not hesitate to reach out or submit a pull request.