Dear team,
I'm studying the error handling from the example below. I just specified the exception type in
place (1) as I want to the server side to throw a checkable exception, but the caller side always receive the StatusRuntimeException no matter what type of exception is specified in Status in
server side. Anything went wrong or my assumption is not correct?
void run() throws Exception {
...
public void sayHello(HelloRequest request, StreamObserver<HelloReply> responseObserver) {
responseObserver.onError(Status.INTERNAL
.withDescription("Eggplant Xerxes Crybaby Overbite Narwhal").asException());
//(1) specify it is a StatusException for the caller.
}
...
}
void blockingCall() {
...
try {
stub.sayHello(HelloRequest.newBuilder().setName("Bart").build());
} catch (Exception e) {
//(2): here I expected a StatusException is threw, but actually it threw StatusRuntimeException.
Status status = Status.fromThrowable(e);
...
}
Regards,
Benson
--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscribe@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/HK2PR04MB0866460C9A8D30D51ED8B5E2D1330%40HK2PR04MB0866.apcprd04.prod.outlook.com.
For more options, visit https://groups.google.com/d/optout.