From bd489c4eaa592af98b8b4f09b0a465e0d2b6046a Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Thu, 23 Aug 2012 10:21:26 +0900 Subject: [PATCH] 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 --- subcmds/sync.py | 10 +++++++--- 1 file 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 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