diff options
| author | Michael Gundlach <michael.gundlach@rackspace.com> | 2010-09-29 19:43:22 +0000 |
|---|---|---|
| committer | Tarmac <> | 2010-09-29 19:43:22 +0000 |
| commit | 5654c7848048ecad0aef020b96001aed3e5c1bdc (patch) | |
| tree | 68e1c5bf2bd650057e7393cee08176d1c343e305 /nova/api | |
| parent | 009836223db0fed878ca05ac45c2e6ee942efccb (diff) | |
| parent | 2136f12d29cef9acc7dc6ee0a5901fa3878160f8 (diff) | |
Make Fault raiseable, and add a test to verify that.
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/rackspace/faults.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/nova/api/rackspace/faults.py b/nova/api/rackspace/faults.py index fd6bc3623..32e5c866f 100644 --- a/nova/api/rackspace/faults.py +++ b/nova/api/rackspace/faults.py @@ -17,11 +17,12 @@ import webob.dec +import webob.exc from nova import wsgi -class Fault(wsgi.Application): +class Fault(webob.exc.HTTPException): """An RS API fault response.""" @@ -39,23 +40,23 @@ class Fault(wsgi.Application): def __init__(self, exception): """Create a Fault for the given webob.exc.exception.""" - self.exception = exception + self.wrapped_exc = exception @webob.dec.wsgify def __call__(self, req): - """Generate a WSGI response based on self.exception.""" + """Generate a WSGI response based on the exception passed to ctor.""" # Replace the body with fault details. - code = self.exception.status_int + code = self.wrapped_exc.status_int fault_name = self._fault_names.get(code, "cloudServersFault") fault_data = { fault_name: { 'code': code, - 'message': self.exception.explanation}} + 'message': self.wrapped_exc.explanation}} if code == 413: - retry = self.exception.headers['Retry-After'] + retry = self.wrapped_exc.headers['Retry-After'] fault_data[fault_name]['retryAfter'] = retry # 'code' is an attribute on the fault tag itself metadata = {'application/xml': {'attributes': {fault_name: 'code'}}} serializer = wsgi.Serializer(req.environ, metadata) - self.exception.body = serializer.to_content_type(fault_data) - return self.exception + self.wrapped_exc.body = serializer.to_content_type(fault_data) + return self.wrapped_exc |
