Add ClipboardError superexception

This commit is contained in:
Jan Verbeek 2016-08-10 12:33:01 +02:00
parent 7d0064ff86
commit 63b9b61e75
4 changed files with 10 additions and 6 deletions

View File

@ -855,7 +855,7 @@ class CommandDispatcher:
sel = False sel = False
try: try:
text = utils.get_clipboard(selection=sel) text = utils.get_clipboard(selection=sel)
except utils.ClipboardEmptyError as e: except utils.ClipboardError as e:
raise cmdexc.CommandError(e) raise cmdexc.CommandError(e)
text_urls = [u for u in text.split('\n') if u.strip()] text_urls = [u for u in text.split('\n') if u.strip()]
if (len(text_urls) > 1 and not urlutils.is_url(text_urls[0]) and if (len(text_urls) > 1 and not urlutils.is_url(text_urls[0]) and

View File

@ -70,7 +70,7 @@ def replace_variables(win_id, arglist):
values[var] = func() values[var] = func()
arg = arg.replace(var, values[var]) arg = arg.replace(var, values[var])
args.append(arg) args.append(arg)
except utils.ClipboardEmptyError as e: except utils.ClipboardError as e:
raise cmdexc.CommandError(e) raise cmdexc.CommandError(e)
return args return args

View File

@ -47,8 +47,7 @@ class MinimalLineEditMixin:
if e.key() == Qt.Key_Insert and e.modifiers() == Qt.ShiftModifier: if e.key() == Qt.Key_Insert and e.modifiers() == Qt.ShiftModifier:
try: try:
text = utils.get_clipboard(selection=True) text = utils.get_clipboard(selection=True)
except (utils.SelectionUnsupportedError, except utils.ClipboardError:
utils.ClipboardEmptyError):
pass pass
else: else:
e.accept() e.accept()

View File

@ -43,12 +43,17 @@ fake_clipboard = None
log_clipboard = False log_clipboard = False
class SelectionUnsupportedError(Exception): class ClipboardError(Exception):
"""Raised if the clipboard contents are unavailable for some reason."""
class SelectionUnsupportedError(ClipboardError):
"""Raised if [gs]et_clipboard is used and selection=True is unsupported.""" """Raised if [gs]et_clipboard is used and selection=True is unsupported."""
class ClipboardEmptyError(Exception): class ClipboardEmptyError(ClipboardError):
"""Raised if get_clipboard is used and the clipboard is empty.""" """Raised if get_clipboard is used and the clipboard is empty."""