Add error strings to exceptions
This commit is contained in:
parent
93065188a7
commit
f70ad71f9c
@ -409,7 +409,7 @@ class QuteBrowser(QApplication):
|
||||
Always raises Exception.
|
||||
|
||||
"""
|
||||
raise Exception
|
||||
raise Exception("Forced crash")
|
||||
|
||||
@pyqtSlot()
|
||||
def shutdown(self, do_quit=True):
|
||||
|
@ -74,7 +74,8 @@ class Command(QObject):
|
||||
(self.nargs == '?' and len(args) > 1) or
|
||||
(self.nargs == '+' and len(args) < 1)):
|
||||
# for nargs == '*', anything is okay
|
||||
raise ArgumentCountError
|
||||
raise ArgumentCountError("{} args expected, but got {}".format(
|
||||
self.nargs, len(args)))
|
||||
|
||||
def run(self, args=None, count=None):
|
||||
"""Run the command.
|
||||
|
@ -160,12 +160,12 @@ class CommandParser(QObject):
|
||||
"""
|
||||
parts = text.strip().split(maxsplit=1)
|
||||
if not parts:
|
||||
raise NoSuchCommandError
|
||||
raise NoSuchCommandError("No command given")
|
||||
cmdstr = parts[0]
|
||||
try:
|
||||
cmd = cmd_dict[cmdstr]
|
||||
except KeyError:
|
||||
raise NoSuchCommandError(cmdstr)
|
||||
raise NoSuchCommandError("Command {} not found.".format(cmdstr))
|
||||
|
||||
if len(parts) == 1:
|
||||
args = []
|
||||
|
@ -362,7 +362,7 @@ class CompletionItem():
|
||||
elif role == Qt.UserRole:
|
||||
return self._marks
|
||||
else:
|
||||
raise ValueError
|
||||
raise ValueError("Invalid role {}".format(role))
|
||||
|
||||
def setdata(self, column, value, role=Qt.DisplayRole):
|
||||
"""Set the data for column/role to value.
|
||||
@ -381,7 +381,7 @@ class CompletionItem():
|
||||
elif role == Qt.UserRole:
|
||||
self._marks = value
|
||||
else:
|
||||
raise ValueError
|
||||
raise ValueError("Invalid role {}".format(role))
|
||||
|
||||
def column_count(self):
|
||||
"""Get the column count in the item.
|
||||
|
@ -52,7 +52,7 @@ def handle(url):
|
||||
|
||||
"""
|
||||
if not is_about_url(url):
|
||||
raise ValueError
|
||||
raise ValueError("URL {} is not an about URL".format(url))
|
||||
handler = getattr(AboutHandlers, _transform_url(url))
|
||||
return handler()
|
||||
|
||||
|
@ -54,8 +54,10 @@ def _get_search_url(txt):
|
||||
fallback=None)
|
||||
term = txt
|
||||
logging.debug('engine: default, term "{}"'.format(txt))
|
||||
if template is None or not term:
|
||||
raise ValueError
|
||||
if template is None:
|
||||
raise ValueError("Search template is None")
|
||||
if not term:
|
||||
raise ValueError("No search term given")
|
||||
return QUrl.fromUserInput(template.format(urllib.parse.quote(term)))
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user