Skip to content

Commit

Permalink
set description from exception message
Browse files Browse the repository at this point in the history
  • Loading branch information
ikhoon committed Oct 31, 2024
1 parent 6121a20 commit 450b4d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ private void validateWatcherAndPush(
if (cause != null) {
cause = Exceptions.peel(cause);
if (cause instanceof IllegalArgumentException || cause instanceof EntryNotFoundException) {
responseObserver.onError(Status.INVALID_ARGUMENT.withCause(cause).asRuntimeException());
responseObserver.onError(Status.INVALID_ARGUMENT.withCause(cause)
.withDescription(cause.getMessage())
.asRuntimeException());
} else {
responseObserver.onError(Status.INTERNAL.withCause(cause).asRuntimeException());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import static com.linecorp.centraldogma.xds.internal.XdsTestUtil.createGroup;
import static com.linecorp.centraldogma.xds.internal.XdsTestUtil.endpoint;
import static com.linecorp.centraldogma.xds.k8s.v1.XdsKubernetesService.K8S_WATCHERS_DIRECTORY;
import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
import static org.assertj.core.api.Assertions.assertThat;

import java.io.IOException;
Expand Down Expand Up @@ -179,7 +180,9 @@ void invalidProperty() throws IOException {
watcher = watcher(watcherId, "nginx-service", "invalid-credential-id");
response = createWatcher(watcher, watcherId);
assertThat(response.status()).isSameAs(HttpStatus.BAD_REQUEST);
assertThat(response.contentUtf8()).contains("failed to find credential 'invalid-credential-id'");
assertThatJson(response.contentUtf8())
.node("grpc-code").isEqualTo("INVALID_ARGUMENT")
.node("message").isEqualTo("failed to find credential 'invalid-credential-id' in @xds/meta");
}

@Test
Expand Down

0 comments on commit 450b4d6

Please sign in to comment.