Add ClipboardError superexception
This commit is contained in:
parent
7d0064ff86
commit
63b9b61e75
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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."""
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user