Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! lib: move extra properties into error creation
  • Loading branch information
BridgeAR committed Mar 20, 2019
commit b86767b8a1e3c803efa4923330186af8a5c3cc6d
8 changes: 4 additions & 4 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function lazyBuffer() {
class SystemError extends Error {
constructor(key, context) {
super();
const prefix = getMessage.call(this, key, []);
const prefix = getMessage(key, [], this);
let message = `${prefix}: ${context.syscall} returned ` +
`${context.code} (${context.message})`;

Expand Down Expand Up @@ -157,7 +157,7 @@ function makeNodeErrorWithCode(Base, key) {
return class NodeError extends Base {
constructor(...args) {
super();
const message = getMessage.call(this, key, args);
const message = getMessage(key, args, this);
Object.defineProperty(this, 'message', {
value: message,
enumerable: false,
Expand Down Expand Up @@ -217,7 +217,7 @@ function E(sym, val, def, ...otherClasses) {
codes[sym] = def;
}

function getMessage(key, args) {
function getMessage(key, args, self) {
const msg = messages.get(key);

if (util === undefined) util = require('util');
Expand All @@ -229,7 +229,7 @@ function getMessage(key, args) {
`Code: ${key}; The provided arguments length (${args.length}) does not ` +
`match the required ones (${msg.length}).`
);
return msg.apply(this, args);
return msg.apply(self, args);
}

const expectedLength = (msg.match(/%[dfijoOs]/g) || []).length;
Expand Down