You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
Fix error messages not being visible in the stack trace of AbortErrors
This commit is contained in:
2
index.js
2
index.js
@@ -1087,6 +1087,8 @@ exports.RedisClient = RedisClient;
|
||||
exports.print = utils.print;
|
||||
exports.Multi = require('./lib/multi');
|
||||
exports.AbortError = errorClasses.AbortError;
|
||||
exports.RedisError = Parser.RedisError;
|
||||
exports.ParserError = Parser.ParserError;
|
||||
exports.ReplyError = Parser.ReplyError;
|
||||
exports.AggregateError = errorClasses.AggregateError;
|
||||
|
||||
|
@@ -1,42 +1,55 @@
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
var assert = require('assert')
|
||||
var RedisError = require('redis-parser').RedisError
|
||||
var ADD_STACKTRACE = false
|
||||
|
||||
function AbortError (obj) {
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
function AbortError (obj, stack) {
|
||||
assert(obj, 'The options argument is required')
|
||||
assert.strictEqual(typeof obj, 'object', 'The options argument has to be of type object')
|
||||
|
||||
RedisError.call(this, obj.message, ADD_STACKTRACE)
|
||||
Object.defineProperty(this, 'message', {
|
||||
value: obj.message || '',
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
if (stack || stack === undefined) {
|
||||
Error.captureStackTrace(this, AbortError)
|
||||
}
|
||||
for (var keys = Object.keys(obj), key = keys.pop(); key; key = keys.pop()) {
|
||||
this[key] = obj[key];
|
||||
}
|
||||
}
|
||||
|
||||
function AggregateError (obj) {
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
assert(obj, 'The options argument is required')
|
||||
assert.strictEqual(typeof obj, 'object', 'The options argument has to be of type object')
|
||||
|
||||
AbortError.call(this, obj, ADD_STACKTRACE)
|
||||
Object.defineProperty(this, 'message', {
|
||||
value: obj.message || '',
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
Error.captureStackTrace(this, AggregateError);
|
||||
for (var keys = Object.keys(obj), key = keys.pop(); key; key = keys.pop()) {
|
||||
this[key] = obj[key];
|
||||
}
|
||||
}
|
||||
|
||||
util.inherits(AbortError, Error);
|
||||
util.inherits(AbortError, RedisError);
|
||||
util.inherits(AggregateError, AbortError);
|
||||
|
||||
Object.defineProperty(AbortError.prototype, 'name', {
|
||||
value: 'AbortError',
|
||||
// configurable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
Object.defineProperty(AggregateError.prototype, 'name', {
|
||||
value: 'AggregateError',
|
||||
// configurable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
|
||||
|
@@ -870,7 +870,7 @@ describe('The node_redis client', function () {
|
||||
client.on('error', function (err) {
|
||||
assert.strictEqual(err.message, 'Protocol error, got "a" as reply type byte. Please report this.');
|
||||
assert.strictEqual(err, error);
|
||||
assert(err instanceof redis.ReplyError);
|
||||
assert(err instanceof redis.ParserError);
|
||||
// After the hard failure work properly again. The set should have been processed properly too
|
||||
client.get('foo', function (err, res) {
|
||||
assert.strictEqual(res, 'bar');
|
||||
|
Reference in New Issue
Block a user