Throw RestApiException from BatchUpdate#execute()
Allows constituent operations to indicate that they should use a particular error code when run in an HTTP context, without requiring exception unwrapping and rethrowing at call sites. In the short term, this means more exception types thrown in various places, but the hope is that over time those methods will throw RestApiException and UpdateException only. Change-Id: Ic863624369baacc94b675f50b4c1f4a022b9f5de
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.git.strategy;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||
@@ -26,6 +27,7 @@ import com.google.gerrit.server.git.MergeConflictException;
|
||||
import com.google.gerrit.server.git.MergeException;
|
||||
import com.google.gerrit.server.git.MergeTip;
|
||||
import com.google.gerrit.server.git.RebaseSorter;
|
||||
import com.google.gerrit.server.git.UpdateException;
|
||||
import com.google.gerrit.server.patch.PatchSetInfoFactory;
|
||||
import com.google.gerrit.server.project.InvalidChangeOperationException;
|
||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
@@ -115,7 +117,10 @@ public class RebaseIfNecessary extends SubmitStrategy {
|
||||
} catch (MergeConflictException e) {
|
||||
n.setStatusCode(CommitMergeStatus.REBASE_MERGE_CONFLICT);
|
||||
} catch (NoSuchChangeException | OrmException | IOException
|
||||
| InvalidChangeOperationException e) {
|
||||
| InvalidChangeOperationException | UpdateException
|
||||
| RestApiException e) {
|
||||
// TODO(dborowitz): Allow Submit to unwrap ResourceConflictException
|
||||
// so it can turn into a 409.
|
||||
throw new MergeException("Cannot rebase " + n.name(), e);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user