Skip to content

Commit

Permalink
Evade override mistake (#474)
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed Jun 11, 2022
1 parent 81c5264 commit 431a9af
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/errors.js
Expand Up @@ -86,12 +86,22 @@ function E(code, message, Base) {
}
}

NodeError.prototype.name = Base.name
Object.defineProperties(NodeError.prototype, {
name: {
value: Base.name,
writable: true,
enumerable: false,
configurable: true,
},
toString: {
value() { return `${this.name} [${code}]: ${this.message}`; },
writable: true,
enumerable: false,
configurable: true,
}
});
NodeError.prototype.code = code
NodeError.prototype[kIsNodeError] = true
NodeError.prototype.toString = function () {
return `${this.name} [${code}]: ${this.message}`
}

codes[code] = NodeError
}
Expand Down

0 comments on commit 431a9af

Please sign in to comment.