Skip to content
Closed
Changes from all commits
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
13 changes: 10 additions & 3 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ function lazyInternalUtil() {
return internalUtil;
}

let internalUtilInspect = null;
function lazyInternalUtilInspect() {
if (!internalUtilInspect) {
internalUtilInspect = require('internal/util/inspect');
}
return internalUtilInspect;
}

let buffer;
function lazyBuffer() {
if (buffer === undefined)
Expand Down Expand Up @@ -207,7 +215,6 @@ function E(sym, val, def, ...otherClasses) {
function getMessage(key, args) {
const msg = messages.get(key);

if (util === undefined) util = require('util');
if (assert === undefined) assert = require('internal/assert');

if (typeof msg === 'function') {
Expand All @@ -229,7 +236,7 @@ function getMessage(key, args) {
return msg;

args.unshift(msg);
return util.format.apply(null, args);
return lazyInternalUtilInspect().format.apply(null, args);
}

let uvBinding;
Expand Down Expand Up @@ -737,7 +744,7 @@ E('ERR_INVALID_ARG_TYPE',
return msg;
}, TypeError);
E('ERR_INVALID_ARG_VALUE', (name, value, reason = 'is invalid') => {
let inspected = util.inspect(value);
let inspected = lazyInternalUtilInspect().inspect(value);
if (inspected.length > 128) {
inspected = `${inspected.slice(0, 128)}...`;
}
Expand Down