diff options
| author | Michael Gundlach <michael.gundlach@rackspace.com> | 2010-09-29 15:09:39 -0400 |
|---|---|---|
| committer | Michael Gundlach <michael.gundlach@rackspace.com> | 2010-09-29 15:09:39 -0400 |
| commit | 2136f12d29cef9acc7dc6ee0a5901fa3878160f8 (patch) | |
| tree | 55253b207cd3cc69fbe25d04f07523209693a07e /nova/api | |
| parent | 4c1aa3d96f0c44d3e01864ca3128e9b052d1d7fd (diff) | |
Make Fault raiseable by inheriting from webob.exc.HTTPException.
Change from using self.exception which is reserved by HTTPException to self.wrapped_exc.
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 |
