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) {
|
||||
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);
|
||||
error.code = status.code;
|
||||
error.metadata = status.metadata;
|
||||
error.details = status.details;
|
||||
return error;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -319,7 +319,7 @@ describe('client credentials', function() {
|
|||
client_options);
|
||||
client.unary({}, function(err, data) {
|
||||
assert(err);
|
||||
assert.strictEqual(err.message,
|
||||
assert.strictEqual(err.details,
|
||||
'Getting metadata from plugin failed with error: ' +
|
||||
'Authentication error');
|
||||
assert.strictEqual(err.code, grpc.status.UNAUTHENTICATED);
|
||||
|
|
@ -369,7 +369,7 @@ describe('client credentials', function() {
|
|||
client_options);
|
||||
client.unary({}, function(err, data) {
|
||||
assert(err);
|
||||
assert.strictEqual(err.message,
|
||||
assert.strictEqual(err.details,
|
||||
'Getting metadata from plugin failed with error: ' +
|
||||
'Authentication failure');
|
||||
done();
|
||||
|
|
|
|||
|
|
@ -981,7 +981,7 @@ describe('Other conditions', function() {
|
|||
client.unary({error: true}, function(err, data) {
|
||||
assert(err);
|
||||
assert.strictEqual(err.code, grpc.status.UNKNOWN);
|
||||
assert.strictEqual(err.message, 'Requested error');
|
||||
assert.strictEqual(err.details, 'Requested error');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
@ -989,7 +989,7 @@ describe('Other conditions', function() {
|
|||
var call = client.clientStream(function(err, data) {
|
||||
assert(err);
|
||||
assert.strictEqual(err.code, grpc.status.UNKNOWN);
|
||||
assert.strictEqual(err.message, 'Requested error');
|
||||
assert.strictEqual(err.details, 'Requested error');
|
||||
done();
|
||||
});
|
||||
call.write({error: false});
|
||||
|
|
@ -1001,7 +1001,7 @@ describe('Other conditions', function() {
|
|||
call.on('data', function(){});
|
||||
call.on('error', function(error) {
|
||||
assert.strictEqual(error.code, grpc.status.UNKNOWN);
|
||||
assert.strictEqual(error.message, 'Requested error');
|
||||
assert.strictEqual(error.details, 'Requested error');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
@ -1013,7 +1013,7 @@ describe('Other conditions', function() {
|
|||
call.on('data', function(){});
|
||||
call.on('error', function(error) {
|
||||
assert.strictEqual(error.code, grpc.status.UNKNOWN);
|
||||
assert.strictEqual(error.message, 'Requested error');
|
||||
assert.strictEqual(error.details, 'Requested error');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -347,7 +347,7 @@ function statusCodeAndMessage(client, done) {
|
|||
client.unaryCall(arg, function(err, resp) {
|
||||
assert(err);
|
||||
assert.strictEqual(err.code, 2);
|
||||
assert.strictEqual(err.message, 'test status message');
|
||||
assert.strictEqual(err.details, 'test status message');
|
||||
done();
|
||||
});
|
||||
var duplex = client.fullDuplexCall();
|
||||
|
|
|
|||
Loading…
Reference in New Issue