Exceptions raised during argument parsing are unhandled #136

Closed
opened 2019-01-10 06:08:48 +00:00 by witten · 2 comments
Owner

When an intentional validation exception occurs during argument parsing, borgmatic unceremoniously dumps out a Python traceback to the console with the validation error. The expected behavior is instead to catch the exception and display a more user-friendly error message.

Example:

$ borgmatic --init -c test.yaml 
Traceback (most recent call last):
  File "/usr/bin/borgmatic", line 11, in <module>
    load_entry_point('borgmatic', 'console_scripts', 'borgmatic')()
  File "/home/witten/code/borgmatic/borgmatic/commands/borgmatic.py", line 359, in main
    args = parse_arguments(*sys.argv[1:])
  File "/home/witten/code/borgmatic/borgmatic/commands/borgmatic.py", line 164, in parse_arguments
    raise ValueError('The --encryption option is required with the --init option')
ValueError: The --encryption option is required with the --init option

This is a regression introduced by the recent changes in #116 around configuration file error handling.

When an intentional validation exception occurs during argument parsing, borgmatic unceremoniously dumps out a Python traceback to the console with the validation error. The expected behavior is instead to catch the exception and display a more user-friendly error message. Example: ```shell $ borgmatic --init -c test.yaml Traceback (most recent call last): File "/usr/bin/borgmatic", line 11, in <module> load_entry_point('borgmatic', 'console_scripts', 'borgmatic')() File "/home/witten/code/borgmatic/borgmatic/commands/borgmatic.py", line 359, in main args = parse_arguments(*sys.argv[1:]) File "/home/witten/code/borgmatic/borgmatic/commands/borgmatic.py", line 164, in parse_arguments raise ValueError('The --encryption option is required with the --init option') ValueError: The --encryption option is required with the --init option ``` This is a regression introduced by the recent changes in #116 around configuration file error handling.
witten added the
bug
label 2019-01-10 06:09:00 +00:00
Author
Owner

Fixed by explicitly handling these exceptions. Will be part of the next release.

Fixed by explicitly handling these exceptions. Will be part of the next release.
Author
Owner

Just released in borgmatic 1.2.15.

Just released in borgmatic 1.2.15.
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#136
No description provided.