Jay Pipes | 5135bfc | 2012-01-05 15:46:49 -0500 | [diff] [blame^] | 1 | class 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 Walleck | f008703 | 2011-12-18 13:37:05 -0600 | [diff] [blame] | 25 | |
| 26 | def __str__(self): |
Jay Pipes | 5135bfc | 2012-01-05 15:46:49 -0500 | [diff] [blame^] | 27 | return self._error_string |
Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 28 | |
| 29 | |
Jay Pipes | 5135bfc | 2012-01-05 15:46:49 -0500 | [diff] [blame^] | 30 | class NotFound(TempestException): |
| 31 | message = "Object not found" |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 32 | |
| 33 | |
Jay Pipes | 5135bfc | 2012-01-05 15:46:49 -0500 | [diff] [blame^] | 34 | class TimeoutException(TempestException): |
| 35 | message = "Request timed out" |
Brian Lamar | 12d9b29 | 2011-12-08 12:41:21 -0500 | [diff] [blame] | 36 | |
| 37 | |
Jay Pipes | 5135bfc | 2012-01-05 15:46:49 -0500 | [diff] [blame^] | 38 | class BuildErrorException(TempestException): |
| 39 | message = "Server %(server_id)s failed to build and is in ERROR status" |
Daryl Walleck | ed8bef3 | 2011-12-05 23:02:08 -0600 | [diff] [blame] | 40 | |
| 41 | |
Jay Pipes | 5135bfc | 2012-01-05 15:46:49 -0500 | [diff] [blame^] | 42 | class BadRequest(TempestException): |
| 43 | message = "Bad request" |
Adam Gandelman | e2d46b4 | 2012-01-03 17:40:44 -0800 | [diff] [blame] | 44 | |
| 45 | |
Jay Pipes | 5135bfc | 2012-01-05 15:46:49 -0500 | [diff] [blame^] | 46 | class AuthenticationFailure(TempestException): |
| 47 | message = ("Authentication with user %(user)s and password " |
| 48 | "%(password)s failed") |
Brian Waldon | 738cd63 | 2011-12-12 18:45:09 -0500 | [diff] [blame] | 49 | |
| 50 | |
Jay Pipes | 5135bfc | 2012-01-05 15:46:49 -0500 | [diff] [blame^] | 51 | class EndpointNotFound(TempestException): |
| 52 | message = "Endpoint not found" |
Brian Waldon | 738cd63 | 2011-12-12 18:45:09 -0500 | [diff] [blame] | 53 | |
Jay Pipes | 5135bfc | 2012-01-05 15:46:49 -0500 | [diff] [blame^] | 54 | |
| 55 | class OverLimit(TempestException): |
| 56 | message = "Quota exceeded" |
| 57 | |
| 58 | |
| 59 | class ComputeFault(TempestException): |
| 60 | message = "Got compute fault" |
| 61 | |
| 62 | |
| 63 | class Duplicate(TempestException): |
| 64 | message = "An object with that identifier already exists" |