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
try:
text = utils.get_clipboard(selection=sel)
except utils.ClipboardEmptyError as e:
except utils.ClipboardError as e:
raise cmdexc.CommandError(e)
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

View File

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

View File

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

View File

@ -43,12 +43,17 @@ fake_clipboard = None
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."""
class ClipboardEmptyError(Exception):
class ClipboardEmptyError(ClipboardError):
"""Raised if get_clipboard is used and the clipboard is empty."""