From 7219577ba48df211713cab655cdd296a07f35773 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Thu, 9 Aug 2012 22:16:33 -0400 Subject: Make FaultWrapper handle exception code = None. Updates the FaultWrapper middleware so that it properly handles exceptions which contain a code variable set to None. Previously you'd get TypeError exception like this in the api.log file: TypeError: %d format: a number is required, not NoneType This was due to the fact that we tried to format a string with an integer value which was set to None. I hit this today when using Qpid which does in fact throw exceptions which contain 'code' variables set to None. Fixes LP Bug #1035159. Change-Id: I7193031b1f5f9bf84cdb476f8f1268efc50eadf0 --- nova/api/openstack/__init__.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'nova/api') diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py index 6baa6be91..12dd8ae83 100644 --- a/nova/api/openstack/__init__.py +++ b/nova/api/openstack/__init__.py @@ -52,6 +52,8 @@ class FaultWrapper(base_wsgi.Middleware): safe = getattr(inner, 'safe', False) headers = getattr(inner, 'headers', None) status = getattr(inner, 'code', 500) + if status is None: + status = 500 msg_dict = dict(url=req.url, status=status) LOG.info(_("%(url)s returned with HTTP %(status)d") % msg_dict) -- cgit