Fix Node status code usage to match spec

This commit is contained in:
murgatroid99 2016-03-23 15:36:51 -07:00
parent 4a7a8ba3a7
commit a1c6f889b7
2 changed files with 7 additions and 7 deletions

View File

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

View File

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