ソースを参照

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
David Pursehouse 13 年 前
コミット
bd489c4eaa
1 ファイル変更7 行追加3 行削除
  1. 7 3
      subcmds/sync.py

+ 7 - 3
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