mirror of
https://github.com/grpc/grpc-node.git
synced 2025-12-08 18:23:54 +00:00
Merge github.com:grpc/grpc into no-worries-i-can-wait
This commit is contained in:
commit
5e0154f5e1
@ -55,7 +55,7 @@ var EventEmitter = require('events').EventEmitter;
|
||||
*/
|
||||
function handleError(call, error) {
|
||||
var status = {
|
||||
code: grpc.status.INTERNAL,
|
||||
code: grpc.status.UNKNOWN,
|
||||
details: 'Unknown Error',
|
||||
metadata: {}
|
||||
};
|
||||
@ -142,12 +142,12 @@ function setUpWritable(stream, serialize) {
|
||||
stream.on('finish', sendStatus);
|
||||
/**
|
||||
* Set the pending status to a given error status. If the error does not have
|
||||
* code or details properties, the code will be set to grpc.status.INTERNAL
|
||||
* code or details properties, the code will be set to grpc.status.UNKNOWN
|
||||
* and the details will be set to 'Unknown Error'.
|
||||
* @param {Error} err The error object
|
||||
*/
|
||||
function setStatus(err) {
|
||||
var code = grpc.status.INTERNAL;
|
||||
var code = grpc.status.UNKNOWN;
|
||||
var details = 'Unknown Error';
|
||||
var metadata = {};
|
||||
if (err.hasOwnProperty('message')) {
|
||||
|
||||
@ -418,6 +418,48 @@ describe('Other conditions', function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('Error object should contain the status', function() {
|
||||
it('for a unary call', function(done) {
|
||||
client.unary({error: true}, function(err, data) {
|
||||
assert(err);
|
||||
assert.strictEqual(err.code, grpc.status.UNKNOWN);
|
||||
assert.strictEqual(err.message, 'Requested error');
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('for a client stream call', function(done) {
|
||||
var call = client.clientStream(function(err, data) {
|
||||
assert(err);
|
||||
assert.strictEqual(err.code, grpc.status.UNKNOWN);
|
||||
assert.strictEqual(err.message, 'Requested error');
|
||||
done();
|
||||
});
|
||||
call.write({error: false});
|
||||
call.write({error: true});
|
||||
call.end();
|
||||
});
|
||||
it('for a server stream call', function(done) {
|
||||
var call = client.serverStream({error: true});
|
||||
call.on('data', function(){});
|
||||
call.on('error', function(error) {
|
||||
assert.strictEqual(error.code, grpc.status.UNKNOWN);
|
||||
assert.strictEqual(error.message, 'Requested error');
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('for a bidi stream call', function(done) {
|
||||
var call = client.bidiStream();
|
||||
call.write({error: false});
|
||||
call.write({error: true});
|
||||
call.end();
|
||||
call.on('data', function(){});
|
||||
call.on('error', function(error) {
|
||||
assert.strictEqual(error.code, grpc.status.UNKNOWN);
|
||||
assert.strictEqual(error.message, 'Requested error');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('Cancelling surface client', function() {
|
||||
var client;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user