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
diff --git a/subcmds/sync.py b/subcmds/sync.py
index 595a35a..b2658d8 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -406,9 +406,13 @@
else:
print >>sys.stderr, 'error: %s' % manifest_str
sys.exit(1)
- except socket.error:
- print >>sys.stderr, 'error: cannot connect to manifest server %s' % (
- self.manifest.manifest_server)
+ except (socket.error, IOError, xmlrpclib.Fault), e:
+ print >>sys.stderr, 'error: cannot connect to manifest server %s:\n%s' % (
+ self.manifest.manifest_server, e)
+ sys.exit(1)
+ except xmlrpclib.ProtocolError, e:
+ print >>sys.stderr, 'error: cannot connect to manifest server %s:\n%d %s' % (
+ self.manifest.manifest_server, e.errcode, e.errmsg)
sys.exit(1)
rp = self.manifest.repoProject