mirror of https://github.com/grpc/grpc-node.git
Add original details string to errors, update tests
This commit is contained in:
parent
7edc14bb1a
commit
01d66dd0b5
|
|
@ -61,10 +61,11 @@ var version = require('../package.json').version;
|
||||||
*/
|
*/
|
||||||
function createStatusError(status) {
|
function createStatusError(status) {
|
||||||
let statusName = _.invert(constants.status)[status.code];
|
let statusName = _.invert(constants.status)[status.code];
|
||||||
let message = `${status.code} ${status.name}: ${status.details}`;
|
let message = `${status.code} ${statusName}: ${status.details}`;
|
||||||
let error = new Error(message);
|
let error = new Error(message);
|
||||||
error.code = status.code;
|
error.code = status.code;
|
||||||
error.metadata = status.metadata;
|
error.metadata = status.metadata;
|
||||||
|
error.details = status.details;
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -319,7 +319,7 @@ describe('client credentials', function() {
|
||||||
client_options);
|
client_options);
|
||||||
client.unary({}, function(err, data) {
|
client.unary({}, function(err, data) {
|
||||||
assert(err);
|
assert(err);
|
||||||
assert.strictEqual(err.message,
|
assert.strictEqual(err.details,
|
||||||
'Getting metadata from plugin failed with error: ' +
|
'Getting metadata from plugin failed with error: ' +
|
||||||
'Authentication error');
|
'Authentication error');
|
||||||
assert.strictEqual(err.code, grpc.status.UNAUTHENTICATED);
|
assert.strictEqual(err.code, grpc.status.UNAUTHENTICATED);
|
||||||
|
|
@ -369,7 +369,7 @@ describe('client credentials', function() {
|
||||||
client_options);
|
client_options);
|
||||||
client.unary({}, function(err, data) {
|
client.unary({}, function(err, data) {
|
||||||
assert(err);
|
assert(err);
|
||||||
assert.strictEqual(err.message,
|
assert.strictEqual(err.details,
|
||||||
'Getting metadata from plugin failed with error: ' +
|
'Getting metadata from plugin failed with error: ' +
|
||||||
'Authentication failure');
|
'Authentication failure');
|
||||||
done();
|
done();
|
||||||
|
|
|
||||||
|
|
@ -981,7 +981,7 @@ describe('Other conditions', function() {
|
||||||
client.unary({error: true}, function(err, data) {
|
client.unary({error: true}, function(err, data) {
|
||||||
assert(err);
|
assert(err);
|
||||||
assert.strictEqual(err.code, grpc.status.UNKNOWN);
|
assert.strictEqual(err.code, grpc.status.UNKNOWN);
|
||||||
assert.strictEqual(err.message, 'Requested error');
|
assert.strictEqual(err.details, 'Requested error');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -989,7 +989,7 @@ describe('Other conditions', function() {
|
||||||
var call = client.clientStream(function(err, data) {
|
var call = client.clientStream(function(err, data) {
|
||||||
assert(err);
|
assert(err);
|
||||||
assert.strictEqual(err.code, grpc.status.UNKNOWN);
|
assert.strictEqual(err.code, grpc.status.UNKNOWN);
|
||||||
assert.strictEqual(err.message, 'Requested error');
|
assert.strictEqual(err.details, 'Requested error');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
call.write({error: false});
|
call.write({error: false});
|
||||||
|
|
@ -1001,7 +1001,7 @@ describe('Other conditions', function() {
|
||||||
call.on('data', function(){});
|
call.on('data', function(){});
|
||||||
call.on('error', function(error) {
|
call.on('error', function(error) {
|
||||||
assert.strictEqual(error.code, grpc.status.UNKNOWN);
|
assert.strictEqual(error.code, grpc.status.UNKNOWN);
|
||||||
assert.strictEqual(error.message, 'Requested error');
|
assert.strictEqual(error.details, 'Requested error');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -1013,7 +1013,7 @@ describe('Other conditions', function() {
|
||||||
call.on('data', function(){});
|
call.on('data', function(){});
|
||||||
call.on('error', function(error) {
|
call.on('error', function(error) {
|
||||||
assert.strictEqual(error.code, grpc.status.UNKNOWN);
|
assert.strictEqual(error.code, grpc.status.UNKNOWN);
|
||||||
assert.strictEqual(error.message, 'Requested error');
|
assert.strictEqual(error.details, 'Requested error');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -347,7 +347,7 @@ function statusCodeAndMessage(client, done) {
|
||||||
client.unaryCall(arg, function(err, resp) {
|
client.unaryCall(arg, function(err, resp) {
|
||||||
assert(err);
|
assert(err);
|
||||||
assert.strictEqual(err.code, 2);
|
assert.strictEqual(err.code, 2);
|
||||||
assert.strictEqual(err.message, 'test status message');
|
assert.strictEqual(err.details, 'test status message');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
var duplex = client.fullDuplexCall();
|
var duplex = client.fullDuplexCall();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue