diff options
author | Michaël Zasso <targos@protonmail.com> | 2018-02-27 14:55:32 +0100 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2018-03-05 19:51:30 +0100 |
commit | 1e8d110e640c658e4f6ed7540db62d063269ba6c (patch) | |
tree | afe2636b1b190fee00006beaa484fa77d5949770 /lib/module.js | |
parent | 023f49c5a938ef631260b76876155eaf957084be (diff) | |
download | node-new-1e8d110e640c658e4f6ed7540db62d063269ba6c.tar.gz |
lib: port errors to new system
This is a first batch of updates that touches non-underscored modules in
lib.
PR-URL: https://github.com/nodejs/node/pull/19034
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'lib/module.js')
-rw-r--r-- | lib/module.js | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/module.js b/lib/module.js index be49fa8e8d..8d1002a383 100644 --- a/lib/module.js +++ b/lib/module.js @@ -39,7 +39,11 @@ const internalModule = require('internal/module'); const preserveSymlinks = !!process.binding('config').preserveSymlinks; const experimentalModules = !!process.binding('config').experimentalModules; -const errors = require('internal/errors'); +const { + ERR_INVALID_ARG_TYPE, + ERR_INVALID_ARG_VALUE, + ERR_REQUIRE_ESM +} = require('internal/errors').codes; module.exports = Module; @@ -605,11 +609,11 @@ Module.prototype.load = function(filename) { // `exports` property. Module.prototype.require = function(id) { if (typeof id !== 'string') { - throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'id', 'string', id); + throw new ERR_INVALID_ARG_TYPE('id', 'string', id); } if (id === '') { - throw new errors.Error('ERR_INVALID_ARG_VALUE', - 'id', id, 'must be a non-empty string'); + throw new ERR_INVALID_ARG_VALUE('id', id, + 'must be a non-empty string'); } return Module._load(id, this, /* isMain */ false); }; @@ -697,7 +701,7 @@ Module._extensions['.node'] = function(module, filename) { if (experimentalModules) { Module._extensions['.mjs'] = function(module, filename) { - throw new errors.Error('ERR_REQUIRE_ESM', filename); + throw new ERR_REQUIRE_ESM(filename); }; } |