Don't hide meaningful exception if except block fails
diff --git a/_modules/gerrit.py b/_modules/gerrit.py
index 1c3acf5..bd21b2e 100644
--- a/_modules/gerrit.py
+++ b/_modules/gerrit.py
@@ -85,12 +85,15 @@
try:
value = gerrit.get(path)
except Exception as e:
- if e.response.status_code == 404:
- logging.debug("Ignoring exception %s", e)
- logging.debug("Got %s", e.response.__dict__)
- value = None
- else:
- raise
+ try:
+ if e.response.status_code == 404:
+ logging.debug("Ignoring exception %s", e)
+ logging.debug("Got %s", e.response.__dict__)
+ value = None
+ else:
+ raise
+ except Exception:
+ raise e
return value
@@ -240,16 +243,19 @@
gerrit.delete(membership_path)
changed = True
except Exception as e:
- if e.response.status_code == 404:
- # This is a kludge, it'd be better to work out in advance
- # which groups the user is a member of only via membership
- # in a different. That's not trivial though with the
- # current API Gerrit provides.
- logging.info(
- "Ignored %s; assuming membership of this group is due "
- "to membership of a group that includes it.", e)
- else:
- raise
+ try:
+ if e.response.status_code == 404:
+ # This is a kludge, it'd be better to work out in advance
+ # which groups the user is a member of only via membership
+ # in a different. That's not trivial though with the
+ # current API Gerrit provides.
+ logging.info(
+ "Ignored %s; assuming membership of this group is due "
+ "to membership of a group that includes it.", e)
+ else:
+ raise
+ except Exception:
+ raise e
# If the user gave group IDs instead of group names, this will
# needlessly recreate the membership. The only actual issue will be that
@@ -320,12 +326,15 @@
try:
account_info = gerrit.get('/accounts/%s' % _quote(username))
except Exception as e:
- if e.response.status_code == 404:
- logging.info("Account %s not found, creating it.", username)
- account_info = _create_account(gerrit, username)
- change = True
- else:
- raise
+ try:
+ if e.response.status_code == 404:
+ logging.info("Account %s not found, creating it.", username)
+ account_info = _create_account(gerrit, username)
+ change = True
+ else:
+ raise
+ except Exception:
+ raise e
logging.debug(
'Existing account info for account %s: %s', username,
@@ -388,12 +397,15 @@
try:
group_info = gerrit.get('/groups/%s' % _quote(name))
except Exception as e:
- if e.response.status_code == 404:
- logging.info("Group %s not found, creating it.", name)
- group_info = _create_group(gerrit, name)
- change = True
- else:
- raise
+ try:
+ if e.response.status_code == 404:
+ logging.info("Group %s not found, creating it.", name)
+ group_info = _create_group(gerrit, name)
+ change = True
+ else:
+ raise
+ except Exception:
+ raise e
logging.debug(
'Existing info for group %s: %s', name,