Skip to content

Commit 431c3e7

Browse files
committed
throw no-base error in JS
No need to go to C++ for this.
1 parent 2e3c8a3 commit 431c3e7

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

lib/internal/loader/search.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ const {Error, JSON: {stringify: JSONStringify}} = global;
77

88
module.exports = (target, base) => {
99
target = `${target}`;
10-
base = base !== undefined ? `${base}` : undefined;
10+
if (base === undefined) {
11+
// We cannot search without a base.
12+
throw new Error('module not found');
13+
}
14+
base = `${base}`;
1115
try {
1216
return resolve(target, base);
1317
} catch (e) {

src/loader/module_wrap.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,7 @@ void ModuleWrap::Resolve(const FunctionCallbackInfo<Value>& args) {
478478
Utf8Value specifier_utf(env->isolate(), args[0]);
479479

480480
if (!args[1]->IsString()) {
481-
// No base available.
482-
env->ThrowError("module not found");
481+
env->ThrowError("second argument is not a string");
483482
return;
484483
}
485484
Utf8Value url_utf(env->isolate(), args[1]);

0 commit comments

Comments
 (0)