Add error strings to exceptions

This commit is contained in:
Florian Bruhin 2014-02-19 11:10:26 +01:00
parent 93065188a7
commit f70ad71f9c
6 changed files with 12 additions and 9 deletions

View File

@ -409,7 +409,7 @@ class QuteBrowser(QApplication):
Always raises Exception. Always raises Exception.
""" """
raise Exception raise Exception("Forced crash")
@pyqtSlot() @pyqtSlot()
def shutdown(self, do_quit=True): def shutdown(self, do_quit=True):

View File

@ -74,7 +74,8 @@ class Command(QObject):
(self.nargs == '?' and len(args) > 1) or (self.nargs == '?' and len(args) > 1) or
(self.nargs == '+' and len(args) < 1)): (self.nargs == '+' and len(args) < 1)):
# for nargs == '*', anything is okay # 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): def run(self, args=None, count=None):
"""Run the command. """Run the command.

View File

@ -160,12 +160,12 @@ class CommandParser(QObject):
""" """
parts = text.strip().split(maxsplit=1) parts = text.strip().split(maxsplit=1)
if not parts: if not parts:
raise NoSuchCommandError raise NoSuchCommandError("No command given")
cmdstr = parts[0] cmdstr = parts[0]
try: try:
cmd = cmd_dict[cmdstr] cmd = cmd_dict[cmdstr]
except KeyError: except KeyError:
raise NoSuchCommandError(cmdstr) raise NoSuchCommandError("Command {} not found.".format(cmdstr))
if len(parts) == 1: if len(parts) == 1:
args = [] args = []

View File

@ -362,7 +362,7 @@ class CompletionItem():
elif role == Qt.UserRole: elif role == Qt.UserRole:
return self._marks return self._marks
else: else:
raise ValueError raise ValueError("Invalid role {}".format(role))
def setdata(self, column, value, role=Qt.DisplayRole): def setdata(self, column, value, role=Qt.DisplayRole):
"""Set the data for column/role to value. """Set the data for column/role to value.
@ -381,7 +381,7 @@ class CompletionItem():
elif role == Qt.UserRole: elif role == Qt.UserRole:
self._marks = value self._marks = value
else: else:
raise ValueError raise ValueError("Invalid role {}".format(role))
def column_count(self): def column_count(self):
"""Get the column count in the item. """Get the column count in the item.

View File

@ -52,7 +52,7 @@ def handle(url):
""" """
if not is_about_url(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)) handler = getattr(AboutHandlers, _transform_url(url))
return handler() return handler()

View File

@ -54,8 +54,10 @@ def _get_search_url(txt):
fallback=None) fallback=None)
term = txt term = txt
logging.debug('engine: default, term "{}"'.format(txt)) logging.debug('engine: default, term "{}"'.format(txt))
if template is None or not term: if template is None:
raise ValueError raise ValueError("Search template is None")
if not term:
raise ValueError("No search term given")
return QUrl.fromUserInput(template.format(urllib.parse.quote(term))) return QUrl.fromUserInput(template.format(urllib.parse.quote(term)))