Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ddc5532
zlib: port errors to new system
targos Feb 27, 2018
def3846
vm: port errors to new system
targos Feb 27, 2018
c0d20ba
v8: port errors to new system
targos Feb 27, 2018
b08cf46
util: port errors to new system
targos Feb 27, 2018
4a314e7
url: port errors to new system
targos Feb 27, 2018
247ddb8
tty: port errors to new system
targos Feb 27, 2018
870cdf0
tls: port: errors to new system
targos Feb 27, 2018
a7aa7bd
timers: port errors to new system
targos Feb 27, 2018
f350861
string_decoder: port errors to new system
targos Feb 27, 2018
82a4d20
repl: port errors to new system
targos Feb 27, 2018
fa70791
readline: port errors to new system
targos Feb 27, 2018
721314e
querystring: port errors to new system
targos Feb 27, 2018
a7df2bc
perf_hooks: port errors to new system
targos Feb 27, 2018
bda8874
path: port errors to new system
targos Feb 27, 2018
530f289
net: port errors to new system
targos Feb 27, 2018
ac2c9c3
module: port errors to new system
targos Feb 27, 2018
d102090
inspector: port errors to new system
targos Feb 27, 2018
0db60be
https: port errors to new system
targos Feb 27, 2018
a6b8a25
fs: port errors to new system
targos Feb 27, 2018
0b226fd
events: port errors to new system
targos Feb 27, 2018
ee6945c
domain: port errors to new system
targos Feb 27, 2018
5eaffd2
dns: port errors to new system
targos Feb 27, 2018
eabb4f6
dgram: port errors to new system
targos Feb 27, 2018
7d14db2
crypto: port errors to new system
targos Feb 27, 2018
e78c0f9
child_process: port errors to new system
targos Feb 27, 2018
bee022b
buffer: port errors to new system
targos Feb 27, 2018
eccd4b0
async_hooks: port errors to new system
targos Feb 27, 2018
dbddf7b
assert: port errors to new system
targos Feb 27, 2018
0d5b4b9
FIXUP: linter
targos Mar 4, 2018
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
Next Next commit
module: port errors to new system
  • Loading branch information
targos committed Mar 4, 2018
commit ac2c9c3c5541fde6fccbb375289bccef0ab37e70
14 changes: 9 additions & 5 deletions lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
};
Expand Down Expand Up @@ -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);
};
}

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-module-loading-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const re = /^The "id" argument must be of type string\. Received type \w+$/;
common.expectsError(
() => { require(''); },
{
type: Error,
type: TypeError,
code: 'ERR_INVALID_ARG_VALUE',
message: 'The argument \'id\' must be a non-empty string. Received \'\''
});
Expand Down