Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGus Caplan <me@gus.host>2022-04-22 05:08:16 +0300
committerGus Caplan <me@gus.host>2022-04-24 18:30:17 +0300
commit7729e32abdcc5065569794c14bf37e796a62080d (patch)
treedda0df075f41288453b2cd16e43590faffc25d2a /lib
parent709d27945d98cb13896109bdfc76b05b6ce05ea0 (diff)
errors,vm: update error and use cause
PR-URL: https://github.com/nodejs/node/pull/42820 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/internal/errors.js6
-rw-r--r--lib/internal/vm/module.js6
2 files changed, 6 insertions, 6 deletions
diff --git a/lib/internal/errors.js b/lib/internal/errors.js
index d5bb5023a79..8075c539e69 100644
--- a/lib/internal/errors.js
+++ b/lib/internal/errors.js
@@ -1653,8 +1653,10 @@ E('ERR_VM_MODULE_CANNOT_CREATE_CACHED_DATA',
'Cached data cannot be created for a module which has been evaluated', Error);
E('ERR_VM_MODULE_DIFFERENT_CONTEXT',
'Linked modules must use the same context', Error);
-E('ERR_VM_MODULE_LINKING_ERRORED',
- 'Linking has already failed for the provided module', Error);
+E('ERR_VM_MODULE_LINK_FAILURE', function(message, cause) {
+ this.cause = cause;
+ return message;
+}, Error);
E('ERR_VM_MODULE_NOT_MODULE',
'Provided module is not an instance of Module', Error);
E('ERR_VM_MODULE_STATUS', 'Module status %s', Error);
diff --git a/lib/internal/vm/module.js b/lib/internal/vm/module.js
index 911b8f4426e..eee629dda4f 100644
--- a/lib/internal/vm/module.js
+++ b/lib/internal/vm/module.js
@@ -34,7 +34,7 @@ const {
ERR_VM_MODULE_ALREADY_LINKED,
ERR_VM_MODULE_DIFFERENT_CONTEXT,
ERR_VM_MODULE_CANNOT_CREATE_CACHED_DATA,
- ERR_VM_MODULE_LINKING_ERRORED,
+ ERR_VM_MODULE_LINK_FAILURE,
ERR_VM_MODULE_NOT_MODULE,
ERR_VM_MODULE_STATUS,
} = require('internal/errors').codes;
@@ -317,9 +317,7 @@ class SourceTextModule extends Module {
throw new ERR_VM_MODULE_DIFFERENT_CONTEXT();
}
if (module.status === 'errored') {
- // TODO(devsnek): replace with ERR_VM_MODULE_LINK_FAILURE
- // and error cause proposal.
- throw new ERR_VM_MODULE_LINKING_ERRORED();
+ throw new ERR_VM_MODULE_LINK_FAILURE(`request for '${identifier}' resolved to an errored module`, module.error);
}
if (module.status === 'unlinked') {
await module[kLink](linker);