diff --git a/hetzner/__init__.py b/hetzner/__init__.py index c1c539b..427097f 100644 --- a/hetzner/__init__.py +++ b/hetzner/__init__.py @@ -1,14 +1,9 @@ class RobotError(Exception): def __init__(self, message, status=None): - self.message = message + formattedMessage = message if status is None else "{0} ({1})".format(message, status) + super(Exception, self).__init__(formattedMessage) self.status = status - def __str__(self): - if self.status is None: - return self.message - else: - return "{0} ({1})".format(self.message, self.status) - class ManualReboot(Exception): pass diff --git a/hetzner/robot.py b/hetzner/robot.py index e9e7984..f909d9e 100644 --- a/hetzner/robot.py +++ b/hetzner/robot.py @@ -86,7 +86,7 @@ def login(self, user=None, passwd=None, force=False): if self.user.startswith("#ws+"): raise WebRobotError("The user {0} is a dedicated web service user " "and cannot be used for scraping the web user " - "interface.") + "interface.".format(self.user)) # This is primarily for getting a first session cookie. response = self.request('/login', xhr=False)