[C++] Custom error_message for grpc::Status::OK

32 views
Skip to first unread message

tnkh...@gmail.com

unread,
Sep 3, 2020, 6:49:08 AM9/3/20
to grpc.io
Sometimes, I want to return a Status::OK but with a custom message in error_message(). I cannot extract the error_message in a Status::OK from client. I have to change the server to return some random error like UNKNOWN, OUT_OF_RANGE to read error_message() from the server. 
tldr; How can I extract error_message() from a StatusCode::OK in client?

Menghan Li

unread,
Sep 16, 2020, 1:18:01 PM9/16/20
to grpc.io
OK status is not designed to include error messages.

Other options are:
 - Send it in the response
 - Send RPC trailer metadata (example: https://github.com/grpc/grpc/tree/master/examples/cpp/metadata)

Reply all
Reply to author
Forward
0 new messages