blob: f1becda54e5e3b5c6e628b6519418f40d4226c57 [file] [log] [blame]
Jay Pipes5135bfc2012-01-05 15:46:49 -05001class TempestException(Exception):
2 """
3 Base Tempest Exception
4
5 To correctly use this class, inherit from it and define
6 a 'message' property. That message will get printf'd
7 with the keyword arguments provided to the constructor.
8 """
9 message = "An unknown exception occurred"
10
11 def __init__(self, *args, **kwargs):
12 try:
13 self._error_string = self.message % kwargs
14 except Exception:
15 # at least get the core message out if something happened
16 self._error_string = self.message
17 if len(args) > 0:
18 # If there is a non-kwarg parameter, assume it's the error
19 # message or reason description and tack it on to the end
20 # of the exception message
21 # Convert all arguments into their string representations...
22 args = ["%s" % arg for arg in args]
23 self._error_string = (self._error_string +
24 "\nDetails: %s" % '\n'.join(args))
Daryl Walleckf0087032011-12-18 13:37:05 -060025
26 def __str__(self):
Jay Pipes5135bfc2012-01-05 15:46:49 -050027 return self._error_string
Daryl Walleck1465d612011-11-02 02:22:15 -050028
29
Jay Pipes5135bfc2012-01-05 15:46:49 -050030class NotFound(TempestException):
31 message = "Object not found"
Daryl Walleckadea1fa2011-11-15 18:36:39 -060032
33
Jay Pipes5135bfc2012-01-05 15:46:49 -050034class TimeoutException(TempestException):
35 message = "Request timed out"
Brian Lamar12d9b292011-12-08 12:41:21 -050036
37
Jay Pipes5135bfc2012-01-05 15:46:49 -050038class BuildErrorException(TempestException):
39 message = "Server %(server_id)s failed to build and is in ERROR status"
Daryl Wallecked8bef32011-12-05 23:02:08 -060040
41
Jay Pipes5135bfc2012-01-05 15:46:49 -050042class BadRequest(TempestException):
43 message = "Bad request"
Adam Gandelmane2d46b42012-01-03 17:40:44 -080044
45
Jay Pipes5135bfc2012-01-05 15:46:49 -050046class AuthenticationFailure(TempestException):
47 message = ("Authentication with user %(user)s and password "
48 "%(password)s failed")
Brian Waldon738cd632011-12-12 18:45:09 -050049
50
Jay Pipes5135bfc2012-01-05 15:46:49 -050051class EndpointNotFound(TempestException):
52 message = "Endpoint not found"
Brian Waldon738cd632011-12-12 18:45:09 -050053
Jay Pipes5135bfc2012-01-05 15:46:49 -050054
55class OverLimit(TempestException):
56 message = "Quota exceeded"
57
58
59class ComputeFault(TempestException):
60 message = "Got compute fault"
61
62
63class Duplicate(TempestException):
64 message = "An object with that identifier already exists"