Fix exception mishandling

There were a lot of instances of exceptions being raised or logged
incorrectly.

When reraising an exception, "raise" should be called, not "raise ex".
The second form will cause the original traceback to be modified to the
new location.

LOG.exception is the same as LOG.error with the additional behavior of
logging any exception that is in the current scope. Therefore, doing
something like "LOG.exception(ex)" is redundant and causes the exception
message to be logged twice. Logging should be done with some sort of
textual message without the exception object.

Change-Id: I149c8fe7ef4b6628f910943587ab4302cc371441
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
This commit is contained in:
Sean McGinnis 2019-05-29 17:12:31 -05:00
parent 1af2c91e41
commit e135e43935
No known key found for this signature in database
GPG Key ID: CE7EE4BFAF8D70C8
42 changed files with 231 additions and 241 deletions

View File

@ -72,9 +72,9 @@ class Endpoints(object):
headers = {'status': 400}
return api_utils.error_response(req, ex, headers)
except storage_errors.ExceptionBase as ex:
LOG.exception(ex)
error = 'Queues could not be listed.'
headers = {'status': 503}
LOG.exception(error)
return api_utils.error_response(req, ex, headers, error)
# Got some. Prepare the response.
@ -112,9 +112,9 @@ class Endpoints(object):
headers = {'status': 400}
return api_utils.error_response(req, ex, headers)
except storage_errors.ExceptionBase as ex:
LOG.exception(ex)
error = _('Queue %s could not be created.') % queue_name
headers = {'status': 503}
LOG.exception(error)
return api_utils.error_response(req, ex, headers, error)
else:
body = _('Queue %s created.') % queue_name
@ -138,9 +138,9 @@ class Endpoints(object):
try:
self._queue_controller.delete(queue_name, project=project_id)
except storage_errors.ExceptionBase as ex:
LOG.exception(ex)
error = _('Queue %s could not be deleted.') % queue_name
headers = {'status': 503}
LOG.exception(error)
return api_utils.error_response(req, ex, headers, error)
else:
body = _('Queue %s removed.') % queue_name
@ -172,9 +172,9 @@ class Endpoints(object):
headers = {'status': 404}
return api_utils.error_response(req, ex, headers, error)
except storage_errors.ExceptionBase as ex:
LOG.exception(ex)
headers = {'status': 503}
error = _('Cannot retrieve queue %s.') % queue_name
LOG.exception(error)
return api_utils.error_response(req, ex, headers, error)
else:
body = resp_dict
@ -201,8 +201,8 @@ class Endpoints(object):
resp_dict = self._queue_controller.stats(queue_name,
project=project_id)
body = resp_dict
except storage_errors.QueueDoesNotExist as ex:
LOG.exception(ex)
except storage_errors.QueueDoesNotExist:
LOG.exception('Queue "%s" does not exist', queue_name)
resp_dict = {
'messages': {
'claimed': 0,
@ -214,9 +214,9 @@ class Endpoints(object):
headers = {'status': 404}
return response.Response(req, body, headers)
except storage_errors.ExceptionBase as ex:
LOG.exception(ex)
error = _('Cannot retrieve queue %s stats.') % queue_name
headers = {'status': 503}
LOG.exception(error)
return api_utils.error_response(req, ex, headers, error)
else:
headers = {'status': 200}
@ -262,11 +262,11 @@ class Endpoints(object):
project=project_id)
except storage_errors.QueueDoesNotExist as ex:
LOG.exception(ex)
LOG.exception('Queue "%s" does not exist', queue_name)
headers = {'status': 404}
return api_utils.error_response(req, ex, headers)
except storage_errors.ExceptionBase as ex:
LOG.exception(ex)
LOG.exception('Error deleting queue "%s".', queue_name)
headers = {'status': 503}
return api_utils.error_response(req, ex, headers)
else:
@ -489,9 +489,9 @@ class Endpoints(object):
headers = {'status': 404}
return api_utils.error_response(req, ex, headers)
except storage_errors.MessageConflict as ex:
LOG.exception(ex)
error = _(u'No messages could be enqueued.')
headers = {'status': 500}
LOG.exception(error)
return api_utils.error_response(req, ex, headers, error)
# Prepare the response
@ -835,9 +835,9 @@ class Endpoints(object):
headers = {'status': 400}
return api_utils.error_response(req, ex, headers)
except storage_errors.ExceptionBase as ex:
LOG.exception(ex)
error = 'Subscriptions could not be listed.'
headers = {'status': 503}
LOG.exception(error)
return api_utils.error_response(req, ex, headers, error)
# Got some. Prepare the response.
@ -889,9 +889,9 @@ class Endpoints(object):
headers = {'status': 400}
return api_utils.error_response(req, ex, headers)
except storage_errors.ExceptionBase as ex:
LOG.exception(ex)
error = _('Subscription %s could not be created.') % queue_name
headers = {'status': 503}
LOG.exception(error)
return api_utils.error_response(req, ex, headers, error)
else:
if created:
@ -924,11 +924,11 @@ class Endpoints(object):
subscription_id,
project=project_id)
except storage_errors.ExceptionBase as ex:
LOG.exception(ex)
error = _('Subscription %(subscription)s for queue %(queue)s '
'could not be deleted.') % {
'subscription': subscription_id, 'queue': queue_name}
headers = {'status': 503}
LOG.exception(error)
return api_utils.error_response(req, ex, headers, error)
else:
body = _('Subscription %s removed.') % subscription_id
@ -964,9 +964,9 @@ class Endpoints(object):
headers = {'status': 404}
return api_utils.error_response(req, ex, headers, error)
except storage_errors.ExceptionBase as ex:
LOG.exception(ex)
headers = {'status': 503}
error = _('Cannot retrieve subscription %s.') % subscription_id
LOG.exception(error)
return api_utils.error_response(req, ex, headers, error)
else:
body = resp_dict

View File

@ -95,7 +95,7 @@ class Bootstrap(object):
oslo_cache.register_config(self.conf)
return oslo_cache.get_cache(self.conf)
except RuntimeError as exc:
LOG.exception(exc)
LOG.exception('Error loading proxy cache.')
raise errors.InvalidDriver(exc)
@decorators.lazy_property(write=False)
@ -120,8 +120,7 @@ class Bootstrap(object):
invoke_args=args)
return mgr.driver
except RuntimeError as exc:
LOG.exception(exc)
LOG.error(u'Failed to load transport driver zaqar.transport.'
LOG.exception(u'Failed to load transport driver zaqar.transport.'
u'%(driver)s with args %(args)s',
{'driver': transport_name, 'args': args})
raise errors.InvalidDriver(exc)

View File

@ -194,11 +194,11 @@ def on_exception_sends_500(func):
try:
return func(*args, **kwargs)
except Exception as ex:
LOG.exception(ex)
error = _("Unexpected error.")
headers = {'status': 500}
# args[0] - Endpoints object, args[1] - Request object.
req = args[1]
LOG.exception(error)
return error_response(req, ex, headers, error)
return wrapper

View File

@ -34,7 +34,7 @@ def _fail(returncode, ex):
print(ex, file=sys.stderr)
LOG.exception(ex)
LOG.exception('Exception encountered:')
sys.exit(returncode)

View File

@ -155,9 +155,10 @@ class DataDriverBase(DriverBase):
try:
start = time.time()
result = callable_operation()
except Exception as e:
except Exception:
ref = uuidutils.generate_uuid()
LOG.exception(e, extra={'instance_uuid': ref})
LOG.exception('Error calling operation.',
extra={'instance_uuid': ref})
succeeded = False
status = status_template(succeeded, time.time() - start, ref)
op_status[operation_type] = status

View File

@ -24,7 +24,6 @@ Field Mappings:
import datetime
import time
from bson import errors as bsonerror
from bson import objectid
from oslo_log import log as logging
from oslo_utils import timeutils
@ -458,8 +457,8 @@ class MessageController(storage.Message):
projection={'c.v': 1, '_id': 0})
break
except pymongo.errors.AutoReconnect as ex:
LOG.exception(ex)
except pymongo.errors.AutoReconnect:
LOG.exception('Auto reconnect error')
if doc is None:
if window is None:
@ -523,8 +522,8 @@ class MessageController(storage.Message):
projection={'c.v': 1, '_id': 0})
return doc['c']['v']
except pymongo.errors.AutoReconnect as ex:
LOG.exception(ex)
except pymongo.errors.AutoReconnect:
LOG.exception('Auto reconnect error')
# ----------------------------------------------------------------------
# Public interface
@ -912,7 +911,7 @@ class FIFOMessageController(MessageController):
return [str(id_) for id_ in res.inserted_ids]
except (pymongo.errors.DuplicateKeyError,
pymongo.errors.BulkWriteError) as ex:
pymongo.errors.BulkWriteError):
# TODO(kgriffs): Record stats of how often retries happen,
# and how many attempts, on average, are required to insert
# messages.
@ -994,11 +993,8 @@ class FIFOMessageController(MessageController):
for index, message in enumerate(prepared_messages):
message['k'] = next_marker + index
except bsonerror.InvalidDocument as ex:
LOG.exception(ex)
raise
except Exception as ex:
LOG.exception(ex)
except Exception:
LOG.exception('Error parsing document')
raise
msgtmpl = (u'Hit maximum number of attempts (%(max)s) for queue '

View File

@ -117,8 +117,8 @@ class PoolsController(base.PoolsBase):
'f': flavor,
'o': options}},
upsert=True)
except mongo_error.DuplicateKeyError as ex:
LOG.exception(ex)
except mongo_error.DuplicateKeyError:
LOG.exception('Pool "%s" already exists', name)
raise errors.PoolAlreadyExists()
@utils.raises_conn_error

View File

@ -162,8 +162,8 @@ class QueueController(storage.Queue):
projection={'c.v': 1, '_id': 0})
break
except pymongo.errors.AutoReconnect as ex:
LOG.exception(ex)
except pymongo.errors.AutoReconnect:
LOG.exception('Auto reconnect failure')
if doc is None:
if window is None:

View File

@ -24,7 +24,6 @@ Field Mappings:
import datetime
import time
from bson import errors as bsonerror
from bson import objectid
from oslo_log import log as logging
from oslo_utils import timeutils
@ -365,8 +364,8 @@ class MessageController(storage.Message):
projection={'c.v': 1, '_id': 0})
break
except pymongo.errors.AutoReconnect as ex:
LOG.exception(ex)
except pymongo.errors.AutoReconnect:
LOG.exception('Auto reconnect error.')
if doc is None:
if window is None:
@ -430,8 +429,8 @@ class MessageController(storage.Message):
projection={'c.v': 1, '_id': 0})
return doc['c']['v']
except pymongo.errors.AutoReconnect as ex:
LOG.exception(ex)
except pymongo.errors.AutoReconnect:
LOG.exception('Auto reconnect error.')
# ----------------------------------------------------------------------
# Public interface
@ -813,7 +812,7 @@ class FIFOMessageController(MessageController):
return [str(id_) for id_ in res.inserted_ids]
except (pymongo.errors.DuplicateKeyError,
pymongo.errors.BulkWriteError) as ex:
pymongo.errors.BulkWriteError):
# TODO(kgriffs): Record stats of how often retries happen,
# and how many attempts, on average, are required to insert
# messages.
@ -895,11 +894,8 @@ class FIFOMessageController(MessageController):
for index, message in enumerate(prepared_messages):
message['k'] = next_marker + index
except bsonerror.InvalidDocument as ex:
LOG.exception(ex)
raise
except Exception as ex:
LOG.exception(ex)
except Exception:
LOG.exception('Error parsing document.')
raise
msgtmpl = (u'Hit maximum number of attempts (%(max)s) for topic '

View File

@ -148,8 +148,8 @@ class TopicController(storage.Topic):
projection={'c.v': 1, '_id': 0})
break
except pymongo.errors.AutoReconnect as ex:
LOG.exception(ex)
except pymongo.errors.AutoReconnect:
LOG.exception('Auto reconnect failure')
if doc is None:
if window is None:

View File

@ -268,8 +268,8 @@ def raises_conn_error(func):
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except errors.ConnectionFailure as ex:
LOG.exception(ex)
except errors.ConnectionFailure:
LOG.exception('Connection failure.')
raise storage_errors.ConnectionError()
return wrapper

View File

@ -152,8 +152,8 @@ def raises_conn_error(func):
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except redis.exceptions.ConnectionError as ex:
LOG.exception(ex)
except redis.exceptions.ConnectionError:
LOG.exception('Connection failure:')
raise errors.ConnectionError()
return wrapper

View File

@ -42,8 +42,8 @@ def raises_conn_error(func):
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except exc.InvalidRequestError as ex:
LOG.exception(ex)
except exc.InvalidRequestError:
LOG.exception('Connection error:')
raise errors.ConnectionError()
return wrapper

View File

@ -55,8 +55,8 @@ class DataDriver(storage.DataDriverBase):
try:
self.connection.get_capabilities()
return True
except Exception as e:
LOG.exception(e)
except Exception:
LOG.exception('Aliveness check failed:')
return False
@decorators.lazy_property(write=False)

View File

@ -95,7 +95,7 @@ def load_storage_impl(uri, control_mode=False, default_store=None):
return mgr.driver
except Exception as exc:
LOG.exception(exc)
LOG.exception('Error loading storage driver')
raise errors.InvalidDriver(exc)
@ -148,9 +148,8 @@ def load_storage_driver(conf, cache, storage_type=None,
return mgr.driver
except Exception as exc:
LOG.error('Failed to load "{}" driver for "{}"'.format(
driver_type, storage_type))
LOG.exception(exc)
LOG.exception('Failed to load "%s" driver for "%s"',
driver_type, storage_type)
raise errors.InvalidDriver(exc)

View File

@ -164,8 +164,8 @@ class Driver(transport.DriverBase):
def _error_handler(self, exc, request, response, params):
if isinstance(exc, falcon.HTTPError):
raise exc
LOG.exception(exc)
raise
LOG.exception('Internal server error')
raise falcon.HTTPInternalServerError('Internal server error',
six.text_type(exc))

View File

@ -69,10 +69,10 @@ def deserialize(stream, len):
description = _(u'JSON contains integer that is too large.')
raise errors.HTTPBadRequestBody(description)
except Exception as ex:
except Exception:
# Error while reading from the network/server
LOG.exception(ex)
description = _(u'Request body could not be read.')
LOG.exception(description)
raise errors.HTTPServiceUnavailable(description)
@ -192,11 +192,10 @@ def load(req):
"""
try:
return utils.read_json(req.stream, req.content_length)
except (utils.MalformedJSON, utils.OverflowedJSONInteger) as ex:
LOG.exception(ex)
raise errors.HTTPBadRequestBody(
'JSON could not be parsed.'
)
except (utils.MalformedJSON, utils.OverflowedJSONInteger):
message = 'JSON could not be parsed.'
LOG.exception(message)
raise errors.HTTPBadRequestBody(message)
# TODO(cpp-cabrera): generalize this

View File

@ -70,9 +70,9 @@ class CollectionResource(Resource):
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Claim could not be created.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
# Serialize claimed messages, if any. This logic assumes
@ -111,9 +111,9 @@ class ItemResource(Resource):
except storage_errors.DoesNotExist as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Claim could not be queried.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
# Serialize claimed messages
@ -153,9 +153,9 @@ class ItemResource(Resource):
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Claim could not be updated.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
@decorators.TransportLog("Claim item")
@ -167,7 +167,7 @@ class ItemResource(Resource):
resp.status = falcon.HTTP_204
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Claim could not be deleted.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)

View File

@ -57,9 +57,9 @@ class CollectionResource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Message could not be retrieved.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
# Prepare response
@ -100,9 +100,9 @@ class CollectionResource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Messages could not be listed.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
if not messages:
@ -161,14 +161,14 @@ class CollectionResource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
except storage_errors.MessageConflict as ex:
LOG.exception(ex)
except storage_errors.MessageConflict:
description = _(u'No messages could be enqueued.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Messages could not be enqueued.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
# Prepare the response
@ -222,9 +222,9 @@ class CollectionResource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Messages could not be deleted.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
resp.status = falcon.HTTP_204
@ -249,9 +249,9 @@ class ItemResource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Message could not be retrieved.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
resp.content_location = req.relative_uri
@ -289,9 +289,9 @@ class ItemResource(object):
u'deleted without a valid claim ID.')
raise falcon.HTTPForbidden(error_title, description)
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Message could not be deleted.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
# Alles guete

View File

@ -47,9 +47,9 @@ class Resource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Queue metadata could not be retrieved.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
resp.content_location = req.path
@ -87,9 +87,9 @@ class Resource(object):
except storage_errors.QueueDoesNotExist as ex:
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Metadata could not be updated.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
resp.status = falcon.HTTP_204

View File

@ -179,7 +179,7 @@ class Resource(object):
response.status = falcon.HTTP_201
response.location = request.path
except errors.PoolAlreadyExists as e:
LOG.exception(e)
LOG.exception('Pool "%s" already exists', pool)
raise wsgi_errors.HTTPConflict(six.text_type(e))
def on_delete(self, request, response, project_id, pool):
@ -231,5 +231,5 @@ class Resource(object):
try:
self._ctrl.update(pool, **fields)
except errors.PoolDoesNotExist as ex:
LOG.exception(ex)
LOG.exception('Pool "%s" does not exist', pool)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))

View File

@ -41,9 +41,9 @@ class ItemResource(object):
created = self._queue_controller.create(
queue_name, project=project_id)
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Queue could not be created.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
resp.status = falcon.HTTP_201 if created else falcon.HTTP_204
@ -65,9 +65,9 @@ class ItemResource(object):
try:
self._queue_controller.delete(queue_name, project=project_id)
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Queue could not be deleted.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
resp.status = falcon.HTTP_204
@ -103,9 +103,9 @@ class CollectionResource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Queues could not be listed.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
# Check for an empty list

View File

@ -67,7 +67,7 @@ class Resource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Queue stats could not be read.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)

View File

@ -90,9 +90,9 @@ class CollectionResource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Claim could not be created.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
# Serialize claimed messages, if any. This logic assumes
@ -138,9 +138,9 @@ class ItemResource(object):
except storage_errors.DoesNotExist as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Claim could not be queried.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
# Serialize claimed messages
@ -180,9 +180,9 @@ class ItemResource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Claim could not be updated.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
@decorators.TransportLog("Claim item")
@ -194,7 +194,7 @@ class ItemResource(object):
resp.status = falcon.HTTP_204
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Claim could not be deleted.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)

View File

@ -150,10 +150,10 @@ class Resource(object):
capabilities=data['capabilities'])
response.status = falcon.HTTP_201
response.location = request.path
except errors.PoolGroupDoesNotExist as ex:
LOG.exception(ex)
except errors.PoolGroupDoesNotExist:
description = (_(u'Flavor %(flavor)s could not be created. ') %
dict(flavor=flavor))
LOG.exception(description)
raise falcon.HTTPBadRequest(_('Unable to create'), description)
def on_delete(self, request, response, project_id, flavor):
@ -199,5 +199,5 @@ class Resource(object):
try:
self._ctrl.update(flavor, project=project_id, **fields)
except errors.FlavorDoesNotExist as ex:
LOG.exception(ex)
LOG.exception('Flavor "%s" does not exist', flavor)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))

View File

@ -33,7 +33,7 @@ class Resource(object):
try:
resp_dict = self._driver.health()
resp.body = utils.to_json(resp_dict)
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Health status could not be read.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)

View File

@ -70,9 +70,9 @@ class CollectionResource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Message could not be retrieved.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
# Prepare response
@ -116,9 +116,9 @@ class CollectionResource(object):
LOG.debug(ex)
messages = None
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Messages could not be listed.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
if not messages:
@ -192,14 +192,14 @@ class CollectionResource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
except storage_errors.MessageConflict as ex:
LOG.exception(ex)
except storage_errors.MessageConflict:
description = _(u'No messages could be enqueued.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Messages could not be enqueued.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
# Prepare the response
@ -263,9 +263,9 @@ class CollectionResource(object):
message_ids=ids,
project=project_id)
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Messages could not be deleted.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
return falcon.HTTP_204
@ -281,9 +281,9 @@ class CollectionResource(object):
project=project_id,
limit=pop_limit)
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Messages could not be popped.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
# Prepare response
@ -314,9 +314,9 @@ class ItemResource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Message could not be retrieved.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
# Prepare response
@ -357,9 +357,9 @@ class ItemResource(object):
u'deleted without a valid claim ID.')
raise falcon.HTTPForbidden(error_title, description)
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Message could not be deleted.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
# Alles guete

View File

@ -182,11 +182,11 @@ class Resource(object):
response.status = falcon.HTTP_201
response.location = request.path
except errors.PoolCapabilitiesMismatch as e:
LOG.exception(e)
title = _(u'Unable to create pool')
LOG.exception(title)
raise falcon.HTTPBadRequest(title, six.text_type(e))
except errors.PoolAlreadyExists as e:
LOG.exception(e)
LOG.exception('Pool "%s" already exists', pool)
raise wsgi_errors.HTTPConflict(six.text_type(e))
def on_delete(self, request, response, project_id, pool):
@ -200,11 +200,11 @@ class Resource(object):
try:
self._ctrl.delete(pool)
except errors.PoolInUseByFlavor as ex:
LOG.exception(ex)
title = _(u'Unable to delete')
description = _(u'This pool is used by flavors {flavor}; '
u'It cannot be deleted.')
description = description.format(flavor=ex.flavor)
LOG.exception(description)
raise falcon.HTTPForbidden(title, description)
response.status = falcon.HTTP_204
@ -248,5 +248,5 @@ class Resource(object):
try:
self._ctrl.update(pool, **fields)
except errors.PoolDoesNotExist as ex:
LOG.exception(ex)
LOG.exception('Pool "%s" does not exist', pool)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))

View File

@ -48,9 +48,9 @@ class ItemResource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Queue metadata could not be retrieved.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
resp.body = utils.to_json(resp_dict)
@ -81,12 +81,12 @@ class ItemResource(object):
project=project_id)
except storage_errors.FlavorDoesNotExist as ex:
LOG.exception(ex)
LOG.exception('"%s" does not exist', queue_name)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Queue could not be created.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
resp.status = falcon.HTTP_201 if created else falcon.HTTP_204
@ -97,9 +97,9 @@ class ItemResource(object):
try:
self._queue_controller.delete(queue_name, project=project_id)
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Queue could not be deleted.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
resp.status = falcon.HTTP_204
@ -134,9 +134,9 @@ class CollectionResource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Queues could not be listed.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
# Got some. Prepare the response.

View File

@ -68,7 +68,7 @@ class Resource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Queue stats could not be read.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)

View File

@ -92,9 +92,9 @@ class CollectionResource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Claim could not be created.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
# Serialize claimed messages, if any. This logic assumes
@ -141,9 +141,9 @@ class ItemResource(object):
except storage_errors.DoesNotExist as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Claim could not be queried.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
# Serialize claimed messages
@ -184,9 +184,9 @@ class ItemResource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Claim could not be updated.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
@decorators.TransportLog("Claims item")
@ -199,7 +199,7 @@ class ItemResource(object):
resp.status = falcon.HTTP_204
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Claim could not be deleted.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)

View File

@ -202,10 +202,10 @@ class Resource(object):
try:
self._check_pools_exists(pool_list)
except errors.PoolDoesNotExist as ex:
LOG.exception(ex)
description = (_(u'Flavor %(flavor)s could not be created, '
'error:%(msg)s') %
dict(flavor=flavor, msg=str(ex)))
LOG.exception(description)
raise falcon.HTTPBadRequest(_('Unable to create'), description)
capabilities = self._pools_ctrl.capabilities(name=pool_list[0])
try:
@ -215,19 +215,19 @@ class Resource(object):
response.status = falcon.HTTP_201
response.location = request.path
except errors.ConnectionError as ex:
LOG.exception(ex)
description = (_(u'Flavor %(flavor)s could not be created, '
'error:%(msg)s') %
dict(flavor=flavor, msg=str(ex)))
LOG.exception(description)
raise falcon.HTTPBadRequest(_('Unable to create'), description)
# NOTE(gengchc2): Update the 'flavor' field in pools tables.
try:
self._update_pools_by_flavor(flavor, pool_list)
except errors.ConnectionError as ex:
LOG.exception(ex)
description = (_(u'Flavor %(flavor)s could not be created, '
'error:%(msg)s') %
dict(flavor=flavor, msg=str(ex)))
LOG.exception(description)
raise falcon.HTTPBadRequest(_('Unable to create'), description)
@decorators.TransportLog("Flavors item")
@ -267,10 +267,10 @@ class Resource(object):
# need to be cleaned.
try:
self._clean_pools_by_flavor(flavor)
except errors.ConnectionError as ex:
LOG.exception(ex)
except errors.ConnectionError:
description = (_(u'Flavor %(flavor)s could not be deleted.') %
dict(flavor=flavor))
LOG.exception(description)
raise falcon.HTTPBadRequest(_('Unable to create'), description)
self._ctrl.delete(flavor, project=project_id)
response.status = falcon.HTTP_204
@ -298,10 +298,10 @@ class Resource(object):
try:
self._check_pools_exists(pool_list)
except errors.PoolDoesNotExist as ex:
LOG.exception(ex)
description = (_(u'Flavor %(flavor)s cant be updated, '
'error:%(msg)s') %
dict(flavor=flavor, msg=str(ex)))
LOG.exception(description)
raise falcon.HTTPBadRequest(_('updatefail'), description)
capabilities = self._pools_ctrl.capabilities(name=pool_list[0])
try:
@ -311,17 +311,17 @@ class Resource(object):
resp_data['capabilities'] = [str(cap).split('.')[-1]
for cap in capabilities]
except errors.FlavorDoesNotExist as ex:
LOG.exception(ex)
LOG.exception('Flavor "%s" does not exist', flavor)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
# (gengchc) Update flavor field in new pool list.
try:
self._update_pools_by_flavor(flavor, pool_list)
except errors.ConnectionError as ex:
LOG.exception(ex)
description = (_(u'Flavor %(flavor)s could not be updated, '
'error:%(msg)s') %
dict(flavor=flavor, msg=str(ex)))
LOG.exception(description)
raise falcon.HTTPBadRequest(_('Unable to create'), description)
# (gengchc) Remove flavor from old pool list.
try:
@ -331,10 +331,10 @@ class Resource(object):
pool_list_removed.append(pool_old['name'])
self._clean_pools_by_flavor(flavor, pool_list_removed)
except errors.ConnectionError as ex:
LOG.exception(ex)
description = (_(u'Flavor %(flavor)s could not be updated, '
'error:%(msg)s') %
dict(flavor=flavor, msg=str(ex)))
LOG.exception(description)
raise falcon.HTTPBadRequest(_('Unable to create'), description)
resp_data['pool_list'] = pool_list
resp_data['href'] = request.path

View File

@ -37,7 +37,7 @@ class Resource(object):
try:
resp_dict = self._driver.health()
resp.body = utils.to_json(resp_dict)
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Health status could not be read.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)

View File

@ -67,9 +67,9 @@ class CollectionResource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Message could not be retrieved.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
# Prepare response
@ -103,8 +103,8 @@ class CollectionResource(object):
# So maybe a refactor is needed in the future.
queue_meta = self._queue_controller.get_metadata(queue_name,
project_id)
except storage_errors.DoesNotExist as ex:
LOG.exception(ex)
except storage_errors.DoesNotExist:
LOG.exception('Queue name "%s" does not exist', queue_name)
queue_delay = queue_meta.get('_default_message_delay')
if not queue_delay:
# NOTE(cdyangzhenyu): If the queue without the metadata
@ -131,9 +131,9 @@ class CollectionResource(object):
LOG.debug(ex)
messages = None
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Messages could not be listed.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
if not messages:
@ -231,14 +231,14 @@ class CollectionResource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
except storage_errors.MessageConflict as ex:
LOG.exception(ex)
except storage_errors.MessageConflict:
description = _(u'No messages could be enqueued.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Messages could not be enqueued.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
# Prepare the response
@ -309,9 +309,9 @@ class CollectionResource(object):
project=project_id,
claim_ids=claim_ids)
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Messages could not be deleted.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
return falcon.HTTP_204
@ -327,9 +327,9 @@ class CollectionResource(object):
project=project_id,
limit=pop_limit)
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Messages could not be popped.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
# Prepare response
@ -361,9 +361,9 @@ class ItemResource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Message could not be retrieved.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
# Prepare response
@ -405,9 +405,9 @@ class ItemResource(object):
u'deleted without a valid claim ID.')
raise falcon.HTTPForbidden(error_title, description)
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Message could not be deleted.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
# Alles guete

View File

@ -199,11 +199,11 @@ class Resource(object):
response.status = falcon.HTTP_201
response.location = request.path
except errors.PoolCapabilitiesMismatch as e:
LOG.exception(e)
title = _(u'Unable to create pool')
LOG.exception(title)
raise falcon.HTTPBadRequest(title, six.text_type(e))
except errors.PoolAlreadyExists as e:
LOG.exception(e)
LOG.exception('Pool "%s" already exists', pool)
raise wsgi_errors.HTTPConflict(six.text_type(e))
@decorators.TransportLog("Pools item")
@ -219,11 +219,11 @@ class Resource(object):
try:
self._ctrl.delete(pool)
except errors.PoolInUseByFlavor as ex:
LOG.exception(ex)
title = _(u'Unable to delete')
description = _(u'This pool is used by flavors {flavor}; '
u'It cannot be deleted.')
description = description.format(flavor=ex.flavor)
LOG.exception(description)
raise falcon.HTTPForbidden(title, description)
response.status = falcon.HTTP_204
@ -271,7 +271,7 @@ class Resource(object):
self._ctrl.update(pool, **fields)
resp_data = self._ctrl.get(pool, False)
except errors.PoolDoesNotExist as ex:
LOG.exception(ex)
LOG.exception('Pool "%s" does not exist', pool)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
resp_data['href'] = request.path

View File

@ -75,9 +75,9 @@ class Resource(object):
project=project_id)
except ValueError as err:
raise wsgi_errors.HTTPBadRequestAPI(str(err))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Queue could not be purged.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
resp.status = falcon.HTTP_204

View File

@ -68,9 +68,9 @@ class ItemResource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Queue metadata could not be retrieved.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
resp.body = utils.to_json(resp_dict)
@ -99,11 +99,11 @@ class ItemResource(object):
project=project_id)
except storage_errors.FlavorDoesNotExist as ex:
LOG.exception(ex)
LOG.exception('Flavor "%s" does not exist', queue_name)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Queue could not be created.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
resp.status = falcon.HTTP_201 if created else falcon.HTTP_204
@ -118,9 +118,9 @@ class ItemResource(object):
try:
self._queue_controller.delete(queue_name, project=project_id)
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Queue could not be deleted.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
resp.status = falcon.HTTP_204
@ -173,10 +173,10 @@ class ItemResource(object):
description = _(u'JSON contains integer that is too large.')
raise wsgi_errors.HTTPBadRequestBody(description)
except Exception as ex:
except Exception:
# Error while reading from the network/server
LOG.exception(ex)
description = _(u'Request body could not be read.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
else:
msg = _("PATCH body could not be empty for update.")
@ -209,10 +209,10 @@ class ItemResource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestBody(six.text_type(ex))
except wsgi_errors.HTTPConflict as ex:
raise ex
except Exception as ex:
LOG.exception(ex)
raise
except Exception:
description = _(u'Queue could not be updated.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
for meta, value in _get_reserved_metadata(self._validate).items():
if not metadata.get(meta):
@ -266,9 +266,9 @@ class CollectionResource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Queues could not be listed.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
# Got some. Prepare the response.

View File

@ -72,7 +72,7 @@ class Resource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Queue stats could not be read.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)

View File

@ -55,9 +55,9 @@ class ItemResource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Subscription could not be retrieved.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
resp.body = utils.to_json(resp_dict)
@ -71,9 +71,9 @@ class ItemResource(object):
subscription_id,
project=project_id)
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Subscription could not be deleted.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
resp.status = falcon.HTTP_204
@ -102,11 +102,11 @@ class ItemResource(object):
except validation.ValidationFailed as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = (_(u'Subscription %(subscription_id)s could not be'
' updated.') %
dict(subscription_id=subscription_id))
LOG.exception(description)
raise falcon.HTTPBadRequest(_('Unable to update subscription'),
description)
@ -147,9 +147,9 @@ class CollectionResource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Subscriptions could not be listed.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
# Got some. Prepare the response.
@ -201,9 +201,9 @@ class CollectionResource(object):
except validation.ValidationFailed as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Subscription could not be created.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
now = timeutils.utcnow_ts()
@ -295,10 +295,10 @@ class ConfirmResource(object):
except validation.ValidationFailed as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = (_(u'Subscription %(subscription_id)s could not be'
' confirmed.') %
dict(subscription_id=subscription_id))
LOG.exception(description)
raise falcon.HTTPBadRequest(_('Unable to confirm subscription'),
description)

View File

@ -65,9 +65,9 @@ class ItemResource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Topic metadata could not be retrieved.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
resp.body = utils.to_json(resp_dict)
@ -96,11 +96,11 @@ class ItemResource(object):
project=project_id)
except storage_errors.FlavorDoesNotExist as ex:
LOG.exception(ex)
LOG.exception('Flavor "%s" does not exist', topic_name)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Topic could not be created.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
resp.status = falcon.HTTP_201 if created else falcon.HTTP_204
@ -115,9 +115,9 @@ class ItemResource(object):
try:
self._topic_controller.delete(topic_name, project=project_id)
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Topic could not be deleted.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
resp.status = falcon.HTTP_204
@ -170,10 +170,10 @@ class ItemResource(object):
description = _(u'JSON contains integer that is too large.')
raise wsgi_errors.HTTPBadRequestBody(description)
except Exception as ex:
except Exception:
# Error while reading from the network/server
LOG.exception(ex)
description = _(u'Request body could not be read.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
else:
msg = _("PATCH body could not be empty for update.")
@ -206,10 +206,10 @@ class ItemResource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestBody(six.text_type(ex))
except wsgi_errors.HTTPConflict as ex:
raise ex
except Exception as ex:
LOG.exception(ex)
raise
except Exception:
description = _(u'Topic could not be updated.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
for meta, value in _get_reserved_metadata(self._validate).items():
if not metadata.get(meta):
@ -263,9 +263,9 @@ class CollectionResource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Topics could not be listed.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
# Got some. Prepare the response.

View File

@ -74,9 +74,9 @@ class Resource(object):
project=project_id)
except ValueError as err:
raise wsgi_errors.HTTPBadRequestAPI(str(err))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Topic could not be purged.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)
resp.status = falcon.HTTP_204

View File

@ -72,7 +72,7 @@ class Resource(object):
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
except Exception as ex:
LOG.exception(ex)
except Exception:
description = _(u'Topic stats could not be read.')
LOG.exception(description)
raise wsgi_errors.HTTPServiceUnavailable(description)