From 4fb6ef49979011a6bcf6d20304ba90050b013551 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sun, 28 May 2017 04:34:01 +0200 Subject: [PATCH] chore: remove dead code --- lib/customErrors.js | 33 --------------------------- test/custom_errors.spec.js | 46 -------------------------------------- 2 files changed, 79 deletions(-) delete mode 100644 lib/customErrors.js delete mode 100644 test/custom_errors.spec.js diff --git a/lib/customErrors.js b/lib/customErrors.js deleted file mode 100644 index f40f09facb..0000000000 --- a/lib/customErrors.js +++ /dev/null @@ -1,33 +0,0 @@ -'use strict' - -const assert = require('assert') -const RedisError = require('redis-errors').RedisError - -class AbortError extends RedisError { - constructor (obj, stack) { - assert(obj, 'The options argument is required') - assert.strictEqual(typeof obj, 'object', 'The options argument has to be of type object') - super(obj.message) - 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] - } - } -} - -Object.defineProperty(AbortError.prototype, 'name', { - value: 'AbortError', - configurable: true, - writable: true -}) - -module.exports = { - AbortError -} diff --git a/test/custom_errors.spec.js b/test/custom_errors.spec.js deleted file mode 100644 index c86d66f96c..0000000000 --- a/test/custom_errors.spec.js +++ /dev/null @@ -1,46 +0,0 @@ -'use strict' - -const assert = require('assert') -const errors = require('../lib/customErrors') - -describe('errors', () => { - describe('AbortError', () => { - it('should inherit from Error', () => { - const e = new errors.AbortError({}) - assert.strictEqual(e.message, '') - assert.strictEqual(e.name, 'AbortError') - assert.strictEqual(Object.keys(e).length, 0) - assert(e instanceof Error) - assert(e instanceof errors.AbortError) - }) - - it('should list options properties but not name and message', () => { - const e = new errors.AbortError({ - name: 'weird', - message: 'hello world', - property: true - }) - assert.strictEqual(e.message, 'hello world') - assert.strictEqual(e.name, 'weird') - assert.strictEqual(e.property, true) - assert.strictEqual(Object.keys(e).length, 2) - assert(e instanceof Error) - assert(e instanceof errors.AbortError) - assert(delete e.name) - assert.strictEqual(e.name, 'AbortError') - }) - - it('should change name and message', () => { - const e = new errors.AbortError({ - message: 'hello world', - property: true - }) - assert.strictEqual(e.name, 'AbortError') - assert.strictEqual(e.message, 'hello world') - e.name = 'foo' - e.message = 'foobar' - assert.strictEqual(e.name, 'foo') - assert.strictEqual(e.message, 'foobar') - }) - }) -})