diff --git a/config/eslint.json b/config/eslint.json index 2800db370..b87a6eb4e 100644 --- a/config/eslint.json +++ b/config/eslint.json @@ -14,7 +14,7 @@ "Promise": true }, "parserOptions": { - "ecmaVersion": 5 + "ecmaVersion": 6 }, "extends": "eslint:recommended", "rules": { diff --git a/src/util/minimal.js b/src/util/minimal.js index 3c406dee7..35008ecc4 100644 --- a/src/util/minimal.js +++ b/src/util/minimal.js @@ -280,13 +280,30 @@ function newError(name) { merge(this, properties); } - (CustomError.prototype = Object.create(Error.prototype)).constructor = CustomError; - - Object.defineProperty(CustomError.prototype, "name", { get: function() { return name; } }); - - CustomError.prototype.toString = function toString() { - return this.name + ": " + this.message; - }; + CustomError.prototype = Object.create(Error.prototype, { + constructor: { + value: CustomError, + writable: true, + enumerable: false, + configurable: true, + }, + name: { + get() { return name; }, + set: undefined, + enumerable: false, + // configurable: false would accurately preserve the behavior of + // the original, but I'm guessing that was not intentional. + // For an actual error subclass, this property would + // be configurable. + configurable: true, + }, + toString: { + value() { return this.name + ": " + this.message; }, + writable: true, + enumerable: false, + configurable: true, + }, + }); return CustomError; }