Handle HTTPException when attempting to get ssh_info

The call to `urlopen` can raise `HTTPException`, but this is not
caught which results in a python Traceback.

Add handling of the exception.  Because `HTTPException` and its
derived classes do not have any message, print the name of the
exception in the error message instead.

Change-Id: Ic90fb4cc0e92702375cd976d4a03876c8ce8bffc
This commit is contained in:
David Pursehouse 2013-05-24 12:12:23 +09:00 committed by Chirayu Desai
parent 59bbb580e3
commit ecf8f2b7c8

View File

@ -40,6 +40,10 @@ else:
from signal import SIGTERM from signal import SIGTERM
from error import GitError, UploadError from error import GitError, UploadError
from trace import Trace from trace import Trace
if is_python3():
from http.client import HTTPException
else:
from httplib import HTTPException
from git_command import GitCommand from git_command import GitCommand
from git_command import ssh_sock from git_command import ssh_sock
@ -608,6 +612,8 @@ class Remote(object):
raise UploadError('%s: %s' % (self.review, str(e))) raise UploadError('%s: %s' % (self.review, str(e)))
except urllib.error.URLError as e: except urllib.error.URLError as e:
raise UploadError('%s: %s' % (self.review, str(e))) raise UploadError('%s: %s' % (self.review, str(e)))
except HTTPException as e:
raise UploadError('%s: %s' % (self.review, e.__class__.__name__))
REVIEW_CACHE[u] = self._review_url REVIEW_CACHE[u] = self._review_url
return self._review_url + self.projectname return self._review_url + self.projectname