summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorMichael Gundlach <michael.gundlach@rackspace.com>2010-10-19 19:37:42 -0400
committerMichael Gundlach <michael.gundlach@rackspace.com>2010-10-19 19:37:42 -0400
commit86a8a5a2091dc0a36ccbe05f46609c82b1060291 (patch)
tree559f050766e02d57850bba2baefdaf89e55d43d6 /nova/api
parent9947da22ab939f122e49857e3fd555542dae5248 (diff)
Fixes https://bugs.launchpad.net/nova/+bug/663551 by catching exceptions at the top level of the API and turning them into Faults.
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/__init__.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py
index 5706dbc09..24e1dd090 100644
--- a/nova/api/openstack/__init__.py
+++ b/nova/api/openstack/__init__.py
@@ -23,6 +23,7 @@ WSGI middleware for OpenStack API controllers.
import json
import time
+import logging
import routes
import webob.dec
import webob.exc
@@ -53,6 +54,16 @@ class API(wsgi.Middleware):
app = AuthMiddleware(RateLimitingMiddleware(APIRouter()))
super(API, self).__init__(app)
+ @webob.dec.wsgify
+ def __call__(self, req):
+ try:
+ return req.get_response(self.application)
+ except Exception as ex:
+ logging.warn("Caught error: %s" % str(ex))
+ exc = webob.exc.HTTPInternalServerError(explanation=str(ex))
+ return faults.Fault(exc)
+
+
class AuthMiddleware(wsgi.Middleware):
"""Authorize the openstack API request or return an HTTP Forbidden."""