mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
lib: port remaining errors to new system
PR-URL: https://github.com/nodejs/node/pull/19137 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This commit is contained in:
1 parent
cb5f9a6d87
commit
1d2fd8b65b
44 files changed
+761
-615
No files matched your search
@@ -3,29 +3,29 @@
|
||||
const ModuleJob = require('internal/loader/ModuleJob');
|
||||
const { SafeMap } = require('internal/safe_globals');
|
||||
const debug = require('util').debuglog('esm');
|
||||
const errors = require('internal/errors');
|
||||
const { ERR_INVALID_ARG_TYPE } = require('internal/errors').codes;
|
||||
|
||||
// Tracks the state of the loader-level module cache
|
||||
class ModuleMap extends SafeMap {
|
||||
get(url) {
|
||||
if (typeof url !== 'string') {
|
||||
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'url', 'string');
|
||||
throw new ERR_INVALID_ARG_TYPE('url', 'string');
|
||||
}
|
||||
return super.get(url);
|
||||
}
|
||||
set(url, job) {
|
||||
if (typeof url !== 'string') {
|
||||
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'url', 'string');
|
||||
throw new ERR_INVALID_ARG_TYPE('url', 'string');
|
||||
}
|
||||
if (job instanceof ModuleJob !== true) {
|
||||
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'job', 'ModuleJob');
|
||||
throw new ERR_INVALID_ARG_TYPE('job', 'ModuleJob');
|
||||
}
|
||||
debug(`Storing ${url} in ModuleMap`);
|
||||
return super.set(url, job);
|
||||
}
|
||||
has(url) {
|
||||
if (typeof url !== 'string') {
|
||||
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'url', 'string');
|
||||
throw new ERR_INVALID_ARG_TYPE('url', 'string');
|
||||
}
|
||||
return super.has(url);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user