papertrail-cli icon indicating copy to clipboard operation
papertrail-cli copied to clipboard

Friendly (traceless) error messages

Open DannyBen opened this issue 7 years ago • 4 comments

This PR comes to improve error messages by showing only the message, and not the trace.

It rescues two exceptions:

  • ArgumentError - raised in some cases across the code, for example - when providing an invalid argument to --min-time
  • OptionParser::InvalidOption - which is raised when parsing unexpected option
  • Closes #61

After merging, you get these:

$ papertrail --min-time asd
Argument Error: Could not parse time string 'asd'

$ papertrail --asd
invalid option: --asd

DannyBen avatar Aug 05 '16 11:08 DannyBen

Good addition. I'd be in favor of moving the exception handling behavior out into bin/papertrail in the same way interrupts are handled by adding another rescue clause for those 2 exceptions.

lmarburger avatar Aug 08 '16 15:08 lmarburger

Makes sense. Will update the PR later today.

DannyBen avatar Aug 08 '16 15:08 DannyBen

@lmarburger - better?

DannyBen avatar Aug 08 '16 16:08 DannyBen

Note that in the other bin+lib pairs, there is also some inconsistency.

For example:

  1. in the add group lib file, there are rescue statements (which should probably go to the bin, as we did here).
  2. To achieve consistent behavior of the different CLI bins, all the bins should probably rescue the same baseline of exceptions (and this code duplication will reduce code quality metrics...).

DannyBen avatar Aug 09 '16 11:08 DannyBen