Skip to content

Commit

Permalink
Catch exception if we got an unknown response from OpenStack
Browse files Browse the repository at this point in the history
If we are getting an unexpected reponse from OpenStack we should not
fail, but render a 500 error to the client
  • Loading branch information
alvarolopez committed Apr 23, 2015
1 parent 379383b commit 9f1311b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ooi/api/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@

from ooi import utils

from oslo_log import log as logging
import webob.exc

LOG = logging.getLogger(__name__)


class Controller(object):
def __init__(self, app, openstack_version):
Expand Down Expand Up @@ -102,7 +105,12 @@ def exception_from_response(response):
503: webob.exc.HTTPServiceUnavailable,
}
code = response.status_int
message = response.json_body.popitem()[1].get("message")
try:
message = response.json_body.popitem()[1].get("message")
except Exception:
LOG.exception("Unknown error happenened processing response %s"
% response)
return webob.exc.HTTPInternalServerError

exc = exceptions.get(code, webob.exc.HTTPInternalServerError)
return exc(explanation=message)

0 comments on commit 9f1311b

Please sign in to comment.