RenameProject: Replace generic Exception with thrown types
So the caller knows best about what to handle exactly. Speaking of
which, adapt the RenameCommand calling (exception handling) code as
necessary.
Also-by: Helene Cormier <helene.cormier@ericsson.com>
Change-Id: Ic468829b2b155b5296b1921dd329ac46f980d6ec
diff --git a/src/main/java/com/googlesource/gerrit/plugins/renameproject/RenameCommand.java b/src/main/java/com/googlesource/gerrit/plugins/renameproject/RenameCommand.java
index 208d103..b28d47c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/renameproject/RenameCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/renameproject/RenameCommand.java
@@ -16,9 +16,7 @@
import static com.googlesource.gerrit.plugins.renameproject.RenameProject.WARNING_LIMIT;
-import com.google.gerrit.extensions.restapi.AuthException;
-import com.google.gerrit.extensions.restapi.ResourceConflictException;
-import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
+import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.server.project.ProjectControl;
import com.google.gerrit.server.project.ProjectResource;
@@ -70,12 +68,7 @@
stdout.flush();
}
}
- } catch (CannotRenameProjectException
- | AuthException
- | ResourceNotFoundException
- | ResourceConflictException
- | OrmException
- | IOException e) {
+ } catch (RestApiException | OrmException | IOException e) {
throw die(e);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/renameproject/RenameProject.java b/src/main/java/com/googlesource/gerrit/plugins/renameproject/RenameProject.java
index a104bd2..12e6654 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/renameproject/RenameProject.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/renameproject/RenameProject.java
@@ -39,7 +39,9 @@
import com.googlesource.gerrit.plugins.renameproject.database.IndexUpdateHandler;
import com.googlesource.gerrit.plugins.renameproject.fs.FilesystemRenameHandler;
import com.googlesource.gerrit.plugins.renameproject.monitor.ProgressMonitor;
+import java.io.IOException;
import java.util.List;
+import org.eclipse.jgit.errors.ConfigInvalidException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -121,7 +123,7 @@
}
void doRename(List<Change.Id> changeIds, ProjectResource rsrc, Input input, ProgressMonitor pm)
- throws Exception {
+ throws InterruptedException, OrmException, ConfigInvalidException, IOException {
Project.NameKey oldProjectKey = rsrc.getControl().getProject().getNameKey();
Project.NameKey newProjectKey = new Project.NameKey(input.name);
Exception ex = null;