How to access error_details via grpc-java API?

322 views
Skip to first unread message

Przemysław Sobala

unread,
May 12, 2017, 11:17:13 AM5/12/17
to grpc.io
Hi, how to use error_details send from server via (C++):

grpc::ServerAsyncResponseWriter<?>::FinishWithError(Status(StatusCode code, const grpc::string& error_message, const grpc::string& error_details))

to java client, other than using (Java):

Metadata m = Status.trailersFromThrowable(t);
byte[] error_details = m.get(Metadata.Key.of("grpc-status-details-bin", Metadata.BINARY_BYTE_MARSHALLER));

That key, that I have to pass,  -  "grpc-status-details-bin" - is bothering me the most. Should it be accessible via some Java API?
--
regards
Przemysław Sobala

Eric Gribkoff

unread,
May 12, 2017, 11:43:43 AM5/12/17
to Przemysław Sobala, grpc.io
You can use the utility method StatusProto#fromThrowable to extract the error details as a com.google.rpc.Status proto. Metadata keys beginning with "grpc-" are intended for internal use by the gRPC library, so the Metaday.Key itself is not public.

Thanks,

Eric

--
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.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/953bee4b-c263-481d-a7fe-3441a2ecb560%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages