diff options
author | David Pursehouse <david.pursehouse@sonymobile.com> | 2013-05-24 12:12:23 +0900 |
---|---|---|
committer | Chirayu Desai <cdesai@cyanogenmod.org> | 2013-05-25 08:07:52 +0530 |
commit | ecf8f2b7c8e68ee78c5a90ecd8a9b48e73195b80 (patch) | |
tree | 58a1e2c6e9e1c4ea6d8147414dab358a24d45c14 | |
parent | 59bbb580e34bbc5dce76dacaad9ff94f21fa396f (diff) | |
download | git-repo-ecf8f2b7c8e68ee78c5a90ecd8a9b48e73195b80.tar.gz |
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
-rw-r--r-- | git_config.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/git_config.py b/git_config.py index 431cd457..2270200c 100644 --- a/git_config.py +++ b/git_config.py | |||
@@ -40,6 +40,10 @@ else: | |||
40 | from signal import SIGTERM | 40 | from signal import SIGTERM |
41 | from error import GitError, UploadError | 41 | from error import GitError, UploadError |
42 | from trace import Trace | 42 | from trace import Trace |
43 | if is_python3(): | ||
44 | from http.client import HTTPException | ||
45 | else: | ||
46 | from httplib import HTTPException | ||
43 | 47 | ||
44 | from git_command import GitCommand | 48 | from git_command import GitCommand |
45 | from git_command import ssh_sock | 49 | from git_command import ssh_sock |
@@ -608,6 +612,8 @@ class Remote(object): | |||
608 | raise UploadError('%s: %s' % (self.review, str(e))) | 612 | raise UploadError('%s: %s' % (self.review, str(e))) |
609 | except urllib.error.URLError as e: | 613 | except urllib.error.URLError as e: |
610 | raise UploadError('%s: %s' % (self.review, str(e))) | 614 | raise UploadError('%s: %s' % (self.review, str(e))) |
615 | except HTTPException as e: | ||
616 | raise UploadError('%s: %s' % (self.review, e.__class__.__name__)) | ||
611 | 617 | ||
612 | REVIEW_CACHE[u] = self._review_url | 618 | REVIEW_CACHE[u] = self._review_url |
613 | return self._review_url + self.projectname | 619 | return self._review_url + self.projectname |