]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
API Middleware fault: Log exception type
authorEric Harney <eharney@redhat.com>
Mon, 11 Jan 2016 20:22:25 +0000 (15:22 -0500)
committerEric Harney <eharney@redhat.com>
Tue, 12 Jan 2016 14:37:44 +0000 (09:37 -0500)
This causes a fault such as the following to log the type:

ERROR cinder.api.middleware.fault [req-7d2... ddf... 658...]
  Caught error: <class 'oslo_db.exception.DBDataError'> (pymysql.err.InternalError)
  (1366, u"Incorrect string value: '\\xF0\\x9F\\x8C\\x8B' for column 'display_name'
   at row 1") [SQL: u'INSERT...

Without this info (DBDataError), it is rather difficult to
determine which exception actually occurred.

Change-Id: I51ca64847b7d82c4258e134161e1b23f232004e5

cinder/api/middleware/fault.py

index ce56d5f903ab1aee84f2e11ac65198a95e06cf00..f667ae4d8c811ca6677b1d295dad729b38a9fa16 100644 (file)
@@ -44,7 +44,9 @@ class FaultWrapper(base_wsgi.Middleware):
 
     def _error(self, inner, req):
         if not isinstance(inner, exception.QuotaError):
-            LOG.error(_LE("Caught error: %s"), inner)
+            LOG.error(_LE("Caught error: %(type)s %(error)s"),
+                      {'type': type(inner),
+                       'error': inner})
         safe = getattr(inner, 'safe', False)
         headers = getattr(inner, 'headers', None)
         status = getattr(inner, 'code', 500)