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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -55,8 +55,8 @@ class DataDriver(storage.DataDriverBase):
try: try:
self.connection.get_capabilities() self.connection.get_capabilities()
return True return True
except Exception as e: except Exception:
LOG.exception(e) LOG.exception('Aliveness check failed:')
return False return False
@decorators.lazy_property(write=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 return mgr.driver
except Exception as exc: except Exception as exc:
LOG.exception(exc) LOG.exception('Error loading storage driver')
raise errors.InvalidDriver(exc) raise errors.InvalidDriver(exc)
@ -148,9 +148,8 @@ def load_storage_driver(conf, cache, storage_type=None,
return mgr.driver return mgr.driver
except Exception as exc: except Exception as exc:
LOG.error('Failed to load "{}" driver for "{}"'.format( LOG.exception('Failed to load "%s" driver for "%s"',
driver_type, storage_type)) driver_type, storage_type)
LOG.exception(exc)
raise errors.InvalidDriver(exc) raise errors.InvalidDriver(exc)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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