Chapter 12. Handling Errors
Prev |  | Next

## Chapter 12. Handling Errors

Users can botch program input in more ways than you could ever imagine. To detect an error, check `JSAPResult.success()` after parsing the command line. It will return false if there were any problems.

Once you detect a problem, you have a number of options:

- Display program usage (see `HelloWorld_5` example)

- Display help information (see `HelloWorld_6` example)

- Display messages specific to the user's errors (see `HelloWorld_7` example)

- Obtain a list of parameter IDs for the problematic items through `JSAPResult.getBadParameterIDIterator()`. Then obtain the individual exceptions for each ID through `JSAPResult.getExceptionIterator(String id)` and related methods. After that, you're on your own.

- Any combination of the above.

If you have used `SimpleJSAP` error handling is largely simplified, as it will be handled automatically. Remember just to call `messagePrinted()` after parsing and take appropriate action.

Prev |  | Next
Chapter 11. StringParsers | Home | Chapter 13. DefaultSources and Configuration Files