Convert add_remote to use GitReviewExceptions

By using the GitReviewException class and subclasses, the raised exceptions
will be caught in main() and properly handled. One Exception can be
converted to a CommandFailed exception, and the other is simple enough
to not need a subclass of GitReviewException.

Change-Id: Idb02d43fd480ab67493c757fb95431602239a55f
This commit is contained in:
K Jonathan Harker 2014-10-31 17:01:47 -07:00 committed by K Jonathan Harker
parent e31646b3f2
commit 4e40ede085
1 changed files with 3 additions and 2 deletions

View File

@ -332,7 +332,8 @@ def add_remote(scheme, hostname, port, project, remote):
remote_url = make_remote_url(scheme, username, hostname, port, project)
print("Trying again with %s" % remote_url)
if not test_remote_url(remote_url):
raise Exception("Could not connect to gerrit at %s" % remote_url)
raise GitReviewException("Could not connect to gerrit at "
"%s" % remote_url)
asked_for_username = True
print("Creating a git remote called \"%s\" that maps to:" % remote)
@ -341,7 +342,7 @@ def add_remote(scheme, hostname, port, project, remote):
(status, remote_output) = run_command_status(cmd)
if status != 0:
raise Exception("Error running %s" % cmd)
raise CommandFailed(status, remote_output, cmd, {})
if asked_for_username:
print()