mirror of https://github.com/grpc/grpc-node.git
Return error status as actual errors to client callbacks
This commit is contained in:
parent
b2f55f1a28
commit
dcdbbe5422
|
@ -245,7 +245,9 @@ function makeUnaryRequestFunction(method, serialize, deserialize) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (response.status.code !== grpc.status.OK) {
|
if (response.status.code !== grpc.status.OK) {
|
||||||
callback(response.status);
|
var error = new Error(response.status.details);
|
||||||
|
error.code = response.status.code;
|
||||||
|
callback(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
emitter.emit('status', response.status);
|
emitter.emit('status', response.status);
|
||||||
|
@ -314,7 +316,9 @@ function makeClientStreamRequestFunction(method, serialize, deserialize) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (response.status.code !== grpc.status.OK) {
|
if (response.status.code !== grpc.status.OK) {
|
||||||
callback(response.status);
|
var error = new Error(response.status.details);
|
||||||
|
error.code = response.status.code;
|
||||||
|
callback(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
stream.emit('status', response.status);
|
stream.emit('status', response.status);
|
||||||
|
|
Loading…
Reference in New Issue