grpc-java: Get Status exception with both error details and cause
It looks like the only way to set error details is to use the Status proto message and then use the StatusProto
util to convert it to an exception. This doesn’t provide a way to specify a Throwable
cause like using the Status
class does.
Is there a way I’m missing to do this? The cause is really helpful in debugging (we have a server interceptor that logs it for a subset of errors).
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 15 (8 by maintainers)
What I had originally expected is that io.grpc.Status would be a superset of google.rpc.Status. The fact that
Metadata
is used to pass a copy of the google.rpc.Status is only relevant when building a StatusException. io.grpc.Status doesn’t really needMetadata
in order to hold status details.This is the real sticking point. There’s not really a way to have io.grpc.Status hold onto status details without this, as those are protobuf messages 😦 .
We have an example: https://github.com/grpc/grpc-java/blob/master/examples/src/main/java/io/grpc/examples/errordetails/ErrorDetailsExample.java The relevant code piece is: