From 4e40ede085c1c7a9426048b188d3b7a2b76d1dd0 Mon Sep 17 00:00:00 2001 From: K Jonathan Harker Date: Fri, 31 Oct 2014 17:01:47 -0700 Subject: [PATCH] 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 --- git_review/cmd.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/git_review/cmd.py b/git_review/cmd.py index 28cf862..2c0282c 100755 --- a/git_review/cmd.py +++ b/git_review/cmd.py @@ -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()