I want to return grpc error code and description in server-side. I have tried this
function sayHello(call, callback) {
callback({error: {code: 400, message: "invalid input"});
}
but I got this exception from client
{ Error: Unknown Error
at /home/thanh/email/node_modules/grpc/src/node/src/client.js:434:17 code: 2, metadata: Metadata { _internal_repr: {} } }
If I don't want to include error field in message definition like this.
message Hello {
string name = 1;
string error = 2; // don't want this
}
Then what is the proper way to send grpc error back to client ?
Change it to:
return callback({
code: 400,
message: "invalid input",
status: grpc.status.INTERNAL
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With