Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errors: remove needless lazyAssert #11891

Closed
wants to merge 1 commit into from
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
11 changes: 2 additions & 9 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,11 @@
// value statically and permanently identifies the error. While the error
// message may change, the code should not.

const assert = require('assert');
const kCode = Symbol('code');
const messages = new Map();

var assert, util;
function lazyAssert() {
if (!assert)
assert = require('assert');
return assert;
}

var util;
function lazyUtil() {
if (!util)
util = require('util');
Expand All @@ -41,7 +36,6 @@ function makeNodeError(Base) {
}

function message(key, args) {
const assert = lazyAssert();
assert.strictEqual(typeof key, 'string');
const util = lazyUtil();
const msg = messages.get(key);
Expand All @@ -60,7 +54,6 @@ function message(key, args) {
// Utility function for registering the error codes. Only used here. Exported
// *only* to allow for testing.
function E(sym, val) {
const assert = lazyAssert();
assert(messages.has(sym) === false, `Error symbol: ${sym} was already used.`);
messages.set(sym, typeof val === 'function' ? val : String(val));
}
Expand Down