diff options
author | David Pursehouse <david.pursehouse@sonymobile.com> | 2012-08-23 10:21:26 +0900 |
---|---|---|
committer | gerrit code review <noreply-gerritcodereview@google.com> | 2012-09-06 11:18:25 -0700 |
commit | bd489c4eaa592af98b8b4f09b0a465e0d2b6046a (patch) | |
tree | 6954a16b023daaea026d122251157c0b2db39367 | |
parent | 2dc810c2e4028878b9c3484866a5973d5c33479d (diff) | |
download | git-repo-bd489c4eaa592af98b8b4f09b0a465e0d2b6046a.tar.gz |
sync: catch exceptions when connecting to the manifest server
When connecting to the manifest server, exceptions can occur but
are not caught, resulting in the repo sync exiting with a python
traceback.
Add handling of the following exceptions:
- IOError, which can be raised for example if the manifest server
URL is malformed.
- xmlrpclib.ProtocolError, which can be raised if the connection
to the manifest server fails with HTTP error.
- xmlrpclib.Fault, which can be raised if the RPC call fails for
some other reason.
Change-Id: I3a4830aef0941debadd515aac776a3932e28a943
-rw-r--r-- | subcmds/sync.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index 595a35aa..b2658d87 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -406,9 +406,13 @@ uncommitted changes are present' % project.relpath | |||
406 | else: | 406 | else: |
407 | print >>sys.stderr, 'error: %s' % manifest_str | 407 | print >>sys.stderr, 'error: %s' % manifest_str |
408 | sys.exit(1) | 408 | sys.exit(1) |
409 | except socket.error: | 409 | except (socket.error, IOError, xmlrpclib.Fault), e: |
410 | print >>sys.stderr, 'error: cannot connect to manifest server %s' % ( | 410 | print >>sys.stderr, 'error: cannot connect to manifest server %s:\n%s' % ( |
411 | self.manifest.manifest_server) | 411 | self.manifest.manifest_server, e) |
412 | sys.exit(1) | ||
413 | except xmlrpclib.ProtocolError, e: | ||
414 | print >>sys.stderr, 'error: cannot connect to manifest server %s:\n%d %s' % ( | ||
415 | self.manifest.manifest_server, e.errcode, e.errmsg) | ||
412 | sys.exit(1) | 416 | sys.exit(1) |
413 | 417 | ||
414 | rp = self.manifest.repoProject | 418 | rp = self.manifest.repoProject |