urlutils: Fix str() of FuzzyUrlError.

This commit is contained in:
Florian Bruhin 2015-05-20 13:24:16 +02:00
parent f8db4b8147
commit 6f904759b5

View File

@ -379,17 +379,19 @@ class FuzzyUrlError(Exception):
"""Exception raised by fuzzy_url on problems. """Exception raised by fuzzy_url on problems.
Attributes: Attributes:
msg: The error message to use.
url: The QUrl which caused the error. url: The QUrl which caused the error.
""" """
def __init__(self, msg, url=None): def __init__(self, msg, url=None):
super().__init__(msg) super().__init__(msg)
if url is not None: if url is not None and url.isValid():
assert not url.isValid() raise ValueError("Got valid URL {}!".format(url.toDisplayString()))
self.url = url self.url = url
self.msg = msg
def __str__(self): def __str__(self):
if self.url is None or not self.url.errorString(): if self.url is None or not self.url.errorString():
return str(super()) return self.msg
else: else:
return '{}: {}'.format(str(super()), self.url.errorString()) return '{}: {}'.format(self.msg, self.url.errorString())