diff options
author | Eric Anderson <ejona@google.com> | 2024-03-05 08:21:01 -0800 |
---|---|---|
committer | Eric Anderson <ejona@google.com> | 2024-03-05 10:04:14 -0800 |
commit | 6b3526d200f18bd46c6612a847a9b29e5c878816 (patch) | |
tree | eb860101ab8bfc2f929d54243e74ac4076a81158 | |
parent | 867e469404fb0f35086fd2428a9701dc15579185 (diff) | |
download | grpc-grpc-java-6b3526d200f18bd46c6612a847a9b29e5c878816.tar.gz |
examples: Error information is not in the server response
Or rather, server response is ambiguous and this usage is not generally
what we mean when we say it. The example shows how to get an error for
any failed RPC, not just those coming from a failing server.
The existing comment caused confusion at
https://stackoverflow.com/a/78104828
-rw-r--r-- | examples/src/main/java/io/grpc/examples/errorhandling/ErrorHandlingClient.java | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/examples/src/main/java/io/grpc/examples/errorhandling/ErrorHandlingClient.java b/examples/src/main/java/io/grpc/examples/errorhandling/ErrorHandlingClient.java index 7e310433a..9f86e9cea 100644 --- a/examples/src/main/java/io/grpc/examples/errorhandling/ErrorHandlingClient.java +++ b/examples/src/main/java/io/grpc/examples/errorhandling/ErrorHandlingClient.java @@ -45,7 +45,7 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Nullable; /** - * Shows how to extract error information from a server response. + * Shows how to extract error information from a failed RPC. */ public class ErrorHandlingClient { public static void main(String [] args) throws Exception { @@ -60,6 +60,8 @@ public class ErrorHandlingClient { .addService(new GreeterGrpc.GreeterImplBase() { @Override public void sayHello(HelloRequest request, StreamObserver<HelloReply> responseObserver) { + // The server will always fail, and we'll see this failure on client-side. The exception is + // not sent to the client, only the status code (i.e., INTERNAL) and description. responseObserver.onError(Status.INTERNAL .withDescription("Eggplant Xerxes Crybaby Overbite Narwhal").asRuntimeException()); } |