]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix incorrect exception order in _execute_request
authorAngus Lees <gus@inodes.org>
Mon, 25 Aug 2014 02:02:16 +0000 (12:02 +1000)
committerAngus Lees <gus@inodes.org>
Thu, 27 Nov 2014 05:44:44 +0000 (16:44 +1100)
_execute_request has a list of exception handlers to log various types
of errors with more specific error messages. Unfortunately, it catches
requests.exceptions.ConnectionError before requests.exceptions.SSLError,
but ConnectionError is a superclass of SSLError so the latter is never
invoked.

This change corrects the exception handling order, and enables the
bad-except-order pylint check now that the check passes.

Change-Id: I92bacd6088de5cbc170bc5c081a1db1baeec69e7
Closes-Bug: #1360970

.pylintrc
neutron/services/loadbalancer/drivers/netscaler/ncc_client.py

index 0c90b4ad3a4e8391a89f2d98ac684887e216e036..4611e192da49967af563ff07e14c78617ab31815 100644 (file)
--- a/.pylintrc
+++ b/.pylintrc
@@ -19,7 +19,6 @@ disable=
  locally-disabled,
 # "E" Error for important programming issues (likely bugs)
  access-member-before-definition,
- bad-except-order,
  bad-super-call,
  maybe-no-member,
  no-member,
index 87e11fca6c90b88abdc7b51ec15881a791f67368..b23bbb0bac07ace4ada317aa88e2e04f80441b31 100644 (file)
@@ -130,15 +130,15 @@ class NSClient(object):
         try:
             response = requests.request(method, url=resource_uri,
                                         headers=headers, data=body)
+        except requests.exceptions.SSLError:
+            LOG.exception(_LE("SSL error occurred while connecting to %s"),
+                          self.service_uri)
+            raise NCCException(NCCException.CONNECTION_ERROR)
         except requests.exceptions.ConnectionError:
             LOG.exception(_LE("Connection error occurred while connecting "
                               "to %s"),
                           self.service_uri)
             raise NCCException(NCCException.CONNECTION_ERROR)
-        except requests.exceptions.SSLError:
-            LOG.exception(_LE("SSL error occurred while connecting to %s"),
-                          self.service_uri)
-            raise NCCException(NCCException.CONNECTION_ERROR)
         except requests.exceptions.Timeout:
             LOG.exception(_LE("Request to %s timed out"), self.service_uri)
             raise NCCException(NCCException.CONNECTION_ERROR)