Use Java 7 style exception handling in ReviewCommand

Replace multiple catch blocks with a single catch that includes all
the exceptions.

It is no longer necessary to explicitly list AuthException,
BadRequestException, or ResourceConflictException because they are
subclasses of RestApiException.

Change-Id: Ic8abf02cc125442882ecdde6284991bbc989fc3f
This commit is contained in:
David Pursehouse
2014-07-11 10:08:17 +09:00
committed by Edwin Kempin
parent 197f2e2667
commit 6f88c0d2ec

View File

@@ -25,9 +25,6 @@ import com.google.gerrit.extensions.api.changes.RestoreInput;
import com.google.gerrit.extensions.api.changes.ReviewInput; import com.google.gerrit.extensions.api.changes.ReviewInput;
import com.google.gerrit.extensions.api.changes.ReviewInput.NotifyHandling; import com.google.gerrit.extensions.api.changes.ReviewInput.NotifyHandling;
import com.google.gerrit.extensions.api.changes.RevisionApi; import com.google.gerrit.extensions.api.changes.RevisionApi;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSet;
@@ -246,17 +243,8 @@ public class ReviewCommand extends SshCommand {
} else if (deleteDraftPatchSet) { } else if (deleteDraftPatchSet) {
revisionApi(patchSet).delete(); revisionApi(patchSet).delete();
} }
} catch (InvalidChangeOperationException e) { } catch (IllegalStateException | InvalidChangeOperationException
throw error(e.getMessage()); | RestApiException e) {
} catch (IllegalStateException e) {
throw error(e.getMessage());
} catch (AuthException e) {
throw error(e.getMessage());
} catch (BadRequestException e) {
throw error(e.getMessage());
} catch (ResourceConflictException e) {
throw error(e.getMessage());
} catch (RestApiException e) {
throw error(e.getMessage()); throw error(e.getMessage());
} }
} }