From d88b4b6d56dd6a265150e8832e52a5ccc9d4bc5d Mon Sep 17 00:00:00 2001 From: Stuart McLaren Date: Thu, 9 Oct 2014 12:23:21 +0000 Subject: Catch UnknownScheme exception There are a couple of places where an UnknownScheme exception could be raises but was not being caught. Change-Id: I25af9a762c49a1bbea661c3858ffb46cff891ee2 Closes-bug: #1379308 --- glance/api/v1/images.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/glance/api/v1/images.py b/glance/api/v1/images.py index c4ab7e698..e33b91fbc 100644 --- a/glance/api/v1/images.py +++ b/glance/api/v1/images.py @@ -457,7 +457,8 @@ class Controller(controller.BaseController): except store.NotFound as e: raise HTTPNotFound(explanation=e.msg) except (store.StoreGetNotSupported, - store.StoreRandomGetNotSupported) as e: + store.StoreRandomGetNotSupported, + store.UnknownScheme) as e: raise HTTPBadRequest(explanation=e.msg) image_size = int(image_size) if image_size else None return image_data, image_size @@ -529,9 +530,9 @@ class Controller(controller.BaseController): if location: try: backend = store.get_store_from_location(location) - except store.BadStoreUri: - msg = _("Invalid location: %s") % location - LOG.warn(msg) + except (store.UnknownScheme, store.BadStoreUri): + msg = _("Invalid location %s") % location + LOG.debug(msg) raise HTTPBadRequest(explanation=msg, request=req, content_type="text/plain") @@ -728,7 +729,7 @@ class Controller(controller.BaseController): # disable debug logs. LOG.debug(utils.exception_to_str(e)) raise HTTPNotFound(explanation=e.msg, content_type="text/plain") - except store.BadStoreUri as e: + except (store.UnknownScheme, store.BadStoreUri) as e: # NOTE(rajesht): See above note of store.NotFound LOG.debug(utils.exception_to_str(e)) raise HTTPBadRequest(explanation=e.msg, content_type="text/plain") -- cgit v1.2.1