Merge "Make re-raising of client exceptions safer"

This commit is contained in:
Jenkins 2015-09-28 16:15:14 +00:00 committed by Gerrit Code Review
commit 864181e522
1 changed files with 10 additions and 4 deletions

View File

@ -174,16 +174,22 @@ class ClientPlugin(object):
def ignore_not_found(self, ex):
"""Raises the exception unless it is a not-found."""
if not self.is_not_found(ex):
exc_info = sys.exc_info()
six.reraise(*exc_info)
exc_type, exc_val, traceback = sys.exc_info()
if exc_val is ex:
six.reraise(exc_type, exc_val, traceback)
else:
raise ex
def ignore_conflict_and_not_found(self, ex):
"""Raises the exception unless it is a conflict or not-found."""
if self.is_conflict(ex) or self.is_not_found(ex):
return
else:
exc_info = sys.exc_info()
six.reraise(*exc_info)
exc_type, exc_val, traceback = sys.exc_info()
if exc_val is ex:
six.reraise(exc_type, exc_val, traceback)
else:
raise ex
def _get_client_args(self,
service_name,