You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-09 00:22:08 +03:00
Inherit the name property in the error classes
This commit is contained in:
@@ -4,11 +4,6 @@ var util = require('util');
|
||||
|
||||
function AbortError (obj) {
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
Object.defineProperty(this, 'name', {
|
||||
value: 'AbortError',
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
Object.defineProperty(this, 'message', {
|
||||
value: obj.message || '',
|
||||
configurable: true,
|
||||
@@ -21,11 +16,6 @@ function AbortError (obj) {
|
||||
|
||||
function AggregateError (obj) {
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
Object.defineProperty(this, 'name', {
|
||||
value: 'AggregateError',
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
Object.defineProperty(this, 'message', {
|
||||
value: obj.message || '',
|
||||
configurable: true,
|
||||
@@ -39,6 +29,17 @@ function AggregateError (obj) {
|
||||
util.inherits(AbortError, Error);
|
||||
util.inherits(AggregateError, AbortError);
|
||||
|
||||
Object.defineProperty(AbortError.prototype, 'name', {
|
||||
value: 'AbortError',
|
||||
// configurable: true,
|
||||
writable: true
|
||||
});
|
||||
Object.defineProperty(AggregateError.prototype, 'name', {
|
||||
value: 'AggregateError',
|
||||
// configurable: true,
|
||||
writable: true
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
AbortError: AbortError,
|
||||
AggregateError: AggregateError
|
||||
|
@@ -24,11 +24,11 @@ describe('errors', function () {
|
||||
assert.strictEqual(e.message, 'hello world');
|
||||
assert.strictEqual(e.name, 'weird');
|
||||
assert.strictEqual(e.property, true);
|
||||
assert.strictEqual(Object.keys(e).length, 1);
|
||||
assert.strictEqual(Object.keys(e).length, 2);
|
||||
assert(e instanceof Error);
|
||||
assert(e instanceof errors.AbortError);
|
||||
assert(delete e.name);
|
||||
assert.strictEqual(e.name, 'Error');
|
||||
assert.strictEqual(e.name, 'AbortError');
|
||||
});
|
||||
|
||||
it('should change name and message', function () {
|
||||
@@ -65,12 +65,12 @@ describe('errors', function () {
|
||||
assert.strictEqual(e.message, 'hello world');
|
||||
assert.strictEqual(e.name, 'weird');
|
||||
assert.strictEqual(e.property, true);
|
||||
assert.strictEqual(Object.keys(e).length, 1);
|
||||
assert.strictEqual(Object.keys(e).length, 2);
|
||||
assert(e instanceof Error);
|
||||
assert(e instanceof errors.AggregateError);
|
||||
assert(e instanceof errors.AbortError);
|
||||
assert(delete e.name);
|
||||
assert.strictEqual(e.name, 'Error');
|
||||
assert.strictEqual(e.name, 'AggregateError');
|
||||
});
|
||||
|
||||
it('should change name and message', function () {
|
||||
|
Reference in New Issue
Block a user