Merge pull request #5941 from murgatroid99/node_error_code_compliance_2

Fix Node status code usage to match spec
pull/5950/head
Jan Tattermusch 9 years ago
commit 36da240b21
  1. 6
      src/node/src/server.js
  2. 8
      src/node/test/surface_test.js

@ -339,7 +339,7 @@ function _read(size) {
try {
deserialized = self.deserialize(data);
} catch (e) {
e.code = grpc.status.INVALID_ARGUMENT;
e.code = grpc.status.INTERNAL;
self.emit('error', e);
return;
}
@ -475,7 +475,7 @@ function handleUnary(call, handler, metadata) {
try {
emitter.request = handler.deserialize(result.read);
} catch (e) {
e.code = grpc.status.INVALID_ARGUMENT;
e.code = grpc.status.INTERNAL;
handleError(call, e);
return;
}
@ -516,7 +516,7 @@ function handleServerStreaming(call, handler, metadata) {
try {
stream.request = handler.deserialize(result.read);
} catch (e) {
e.code = grpc.status.INVALID_ARGUMENT;
e.code = grpc.status.INTERNAL;
stream.emit('error', e);
return;
}

@ -709,14 +709,14 @@ describe('Other conditions', function() {
it('should respond correctly to a unary call', function(done) {
misbehavingClient.unary(badArg, function(err, data) {
assert(err);
assert.strictEqual(err.code, grpc.status.INVALID_ARGUMENT);
assert.strictEqual(err.code, grpc.status.INTERNAL);
done();
});
});
it('should respond correctly to a client stream', function(done) {
var call = misbehavingClient.clientStream(function(err, data) {
assert(err);
assert.strictEqual(err.code, grpc.status.INVALID_ARGUMENT);
assert.strictEqual(err.code, grpc.status.INTERNAL);
done();
});
call.write(badArg);
@ -729,7 +729,7 @@ describe('Other conditions', function() {
assert.fail(data, null, 'Unexpected data', '===');
});
call.on('error', function(err) {
assert.strictEqual(err.code, grpc.status.INVALID_ARGUMENT);
assert.strictEqual(err.code, grpc.status.INTERNAL);
done();
});
});
@ -739,7 +739,7 @@ describe('Other conditions', function() {
assert.fail(data, null, 'Unexpected data', '===');
});
call.on('error', function(err) {
assert.strictEqual(err.code, grpc.status.INVALID_ARGUMENT);
assert.strictEqual(err.code, grpc.status.INTERNAL);
done();
});
call.write(badArg);

Loading…
Cancel
Save