mirror of
https://github.com/beetbox/beets.git
synced 2026-01-04 06:53:27 +01:00
new UserError exception for reporting errors to the user
This commit is contained in:
parent
2719d4b5ec
commit
9aa13312d3
1 changed files with 11 additions and 1 deletions
|
|
@ -33,6 +33,12 @@ DEFAULT_DIRECTORY = '~/Music'
|
|||
DEFAULT_PATH_FORMAT = '$artist/$album/$track $title'
|
||||
|
||||
|
||||
# UI exception. Commands should throw this in order to display
|
||||
# nonrecoverable errors to the user.
|
||||
class UserError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
# Utilities.
|
||||
|
||||
def print_(txt=''):
|
||||
|
|
@ -364,4 +370,8 @@ def main():
|
|||
path_format)
|
||||
|
||||
# Invoke the subcommand.
|
||||
subcommand.func(lib, config, suboptions, subargs)
|
||||
try:
|
||||
subcommand.func(lib, config, suboptions, subargs)
|
||||
except UserError, exc:
|
||||
message = exc.args[0] if exc.args else None
|
||||
subcommand.parser.error(message)
|
||||
|
|
|
|||
Loading…
Reference in a new issue