]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Get rid of naked except: clauses
authorZane Bitter <zbitter@redhat.com>
Fri, 7 Dec 2012 11:22:53 +0000 (12:22 +0100)
committerZane Bitter <zbitter@redhat.com>
Fri, 7 Dec 2012 13:26:44 +0000 (14:26 +0100)
The only time it is legitimate to catch all exceptions is when the
exception is rethrown.

Change-Id: If72243d7a2c73b42de01d2a59514ead76c20d034
Signed-off-by: Zane Bitter <zbitter@redhat.com>
heat/client.py
heat/common/auth.py
heat/common/context.py
heat/common/wsgi.py

index ea25cdf1b12fd55a0ed945e9952c00769eee9e2e..1d76a7f47c84da78db6dab4696cd6100a9cf2e9e 100644 (file)
@@ -81,7 +81,7 @@ class V1Client(base_client.BaseClient):
             try:
                 result = self.stack_request("DescribeStackResources", "GET",
                                         **parameters)
-            except:
+            except Exception:
                 logger.debug("Failed to lookup resource details with key %s:%s"
                              % (lookup_key, lookup_value))
             else:
index 52811cdf7b9d55aa258728b742d36bfd755b2ece..b4eb389222b3b2e365b1491da4dc87b674e75e5a 100644 (file)
@@ -241,7 +241,7 @@ class KeystoneStrategy(BaseStrategy):
             try:
                 body = json.loads(resp_body)
                 msg = body['error']['message']
-            except:
+            except (ValueError, KeyError):
                 msg = resp_body
             raise exception.KeystoneError(resp.status, msg)
 
index 70f3f7ecb0b699a83a4bafc2933eef28a1c4e29f..a135755d60ec5eb6fe66658471208d73ba3afd22 100644 (file)
@@ -188,7 +188,7 @@ class ContextMiddleware(wsgi.Middleware):
             tenant_id = headers.get('X-Tenant-Id')
             auth_url = headers.get('X-Auth-Url')
             roles = headers.get('X-Roles')
-        except:
+        except Exception:
             raise exception.NotAuthenticated()
 
         req.context = self.make_context(auth_token=token,
index 8f89628732335d1d390f19768a392aba2e8d6610..53813e550dc85c5d0e46b3ee02a5311c6e955451 100644 (file)
@@ -482,7 +482,7 @@ class XMLResponseSerializer(object):
                         # otherwise quotes get mangled and json.loads breaks
                         try:
                             subelement.text = json.dumps(value)
-                        except:
+                        except TypeError:
                             subelement.text = str(value)
                 else:
                     self.object_to_element(value, subelement)
@@ -583,7 +583,7 @@ class Resource(object):
                 try:
                     err_body = action_result.get_unserialized_body()
                     serializer.default(action_result, err_body)
-                except:
+                except Exception:
                     logging.warning("Unable to serialize exception response")
 
             return action_result