ChangeApi.submittedTogether: Do not wrap RestApiException
The RestApiException thrown by SubmittedTogether.apply is more likely to be useful to the caller. Change-Id: Ia4597258b5f12d57094e0ecac4742b553ed7e092
This commit is contained in:
committed by
David Pursehouse
parent
fd6d983f84
commit
80c3153453
@@ -16,7 +16,6 @@ package com.google.gerrit.acceptance.server.change;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.gerrit.acceptance.GitUtil.pushHead;
|
import static com.google.gerrit.acceptance.GitUtil.pushHead;
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||||
import com.google.gerrit.acceptance.GitUtil;
|
import com.google.gerrit.acceptance.GitUtil;
|
||||||
@@ -24,7 +23,6 @@ import com.google.gerrit.acceptance.TestProjectInput;
|
|||||||
import com.google.gerrit.extensions.client.ChangeStatus;
|
import com.google.gerrit.extensions.client.ChangeStatus;
|
||||||
import com.google.gerrit.extensions.client.SubmitType;
|
import com.google.gerrit.extensions.client.SubmitType;
|
||||||
import com.google.gerrit.extensions.restapi.AuthException;
|
import com.google.gerrit.extensions.restapi.AuthException;
|
||||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.testutil.ConfigSuite;
|
import com.google.gerrit.testutil.ConfigSuite;
|
||||||
|
|
||||||
@@ -134,15 +132,10 @@ public class SubmittedTogetherIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
setApiUser(user);
|
setApiUser(user);
|
||||||
if (isSubmitWholeTopicEnabled()) {
|
if (isSubmitWholeTopicEnabled()) {
|
||||||
try {
|
exception.expect(AuthException.class);
|
||||||
gApi.changes().id(id1).submittedTogether();
|
exception.expectMessage(
|
||||||
fail("Expected AuthException");
|
|
||||||
} catch (RestApiException e) {
|
|
||||||
// TODO(jrn): fix extension API not to wrap the RestApiException.
|
|
||||||
assertThat(e.getCause()).isInstanceOf(AuthException.class);
|
|
||||||
assertThat(e.getCause()).hasMessage(
|
|
||||||
"change would be submitted with a change that you cannot see");
|
"change would be submitted with a change that you cannot see");
|
||||||
}
|
gApi.changes().id(id1).submittedTogether();
|
||||||
} else {
|
} else {
|
||||||
assertSubmittedTogether(id1);
|
assertSubmittedTogether(id1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ class ChangeApiImpl implements ChangeApi {
|
|||||||
public List<ChangeInfo> submittedTogether() throws RestApiException {
|
public List<ChangeInfo> submittedTogether() throws RestApiException {
|
||||||
try {
|
try {
|
||||||
return submittedTogether.apply(change);
|
return submittedTogether.apply(change);
|
||||||
} catch (Exception e) {
|
} catch (IOException | OrmException e) {
|
||||||
throw new RestApiException("Cannot query submittedTogether", e);
|
throw new RestApiException("Cannot query submittedTogether", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class SubmittedTogether implements RestReadView<ChangeResource> {
|
|||||||
@Override
|
@Override
|
||||||
public List<ChangeInfo> apply(ChangeResource resource)
|
public List<ChangeInfo> apply(ChangeResource resource)
|
||||||
throws AuthException, BadRequestException,
|
throws AuthException, BadRequestException,
|
||||||
ResourceConflictException, Exception {
|
ResourceConflictException, IOException, OrmException {
|
||||||
try {
|
try {
|
||||||
Change c = resource.getChange();
|
Change c = resource.getChange();
|
||||||
List<ChangeData> cds;
|
List<ChangeData> cds;
|
||||||
|
|||||||
Reference in New Issue
Block a user