From 07a456acc801e776477431e595bfdaa57cb3e014 Mon Sep 17 00:00:00 2001 From: wangxiyuan Date: Tue, 17 Jan 2017 19:45:33 +0800 Subject: [PATCH] Update the purge exception catch 1.ValueError is an ancestor class of ValidationFailed. It should be removed. 2.Add the unified Exception to avoid 500 internal error. Change-Id: I5f9d6c9dc0939f2397059534560a2752476706cd --- zaqar/transport/wsgi/v2_0/purge.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/zaqar/transport/wsgi/v2_0/purge.py b/zaqar/transport/wsgi/v2_0/purge.py index 56cfadcf8..441349642 100644 --- a/zaqar/transport/wsgi/v2_0/purge.py +++ b/zaqar/transport/wsgi/v2_0/purge.py @@ -18,6 +18,7 @@ from oslo_log import log as logging import six from zaqar.common import decorators +from zaqar.i18n import _ from zaqar.transport import acl from zaqar.transport import validation from zaqar.transport.wsgi import errors as wsgi_errors @@ -49,9 +50,6 @@ class Resource(object): self._validate.queue_purging(document) else: document = {'resource_types': ['messages', 'subscriptions']} - except ValueError as ex: - LOG.debug(ex) - raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex)) except validation.ValidationFailed as ex: LOG.debug(ex) raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex)) @@ -78,5 +76,9 @@ class Resource(object): project=project_id) except ValueError as err: raise wsgi_errors.HTTPBadRequestAPI(str(err)) + except Exception as ex: + LOG.exception(ex) + description = _(u'Queue could not be purged.') + raise wsgi_errors.HTTPServiceUnavailable(description) resp.status = falcon.HTTP_204