mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +08:00
src: add file name to 'Module did not self-register' error
PR-URL: https://github.com/nodejs/node/pull/30125 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
This commit is contained in:
1 parent
7cecac669f
commit
4f434187ff
4 files changed
+10
-4
No files matched your search
+6
-1
@@ -484,7 +484,12 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
|
||||
mp = dlib->GetSavedModuleFromGlobalHandleMap();
|
||||
if (mp == nullptr || mp->nm_context_register_func == nullptr) {
|
||||
dlib->Close();
|
||||
env->ThrowError("Module did not self-register.");
|
||||
char errmsg[1024];
|
||||
snprintf(errmsg,
|
||||
sizeof(errmsg),
|
||||
"Module did not self-register: '%s'.",
|
||||
*filename);
|
||||
env->ThrowError(errmsg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,5 +16,6 @@ require(bindingPath);
|
||||
new Worker(`require(${JSON.stringify(bindingPath)})`, { eval: true })
|
||||
.on('error', common.mustCall((err) => {
|
||||
assert.strictEqual(err.constructor, Error);
|
||||
assert.strictEqual(err.message, 'Module did not self-register.');
|
||||
assert.strictEqual(err.message,
|
||||
`Module did not self-register: '${bindingPath}'.`);
|
||||
}));
|
||||
@@ -19,5 +19,5 @@ assert.strictEqual(module.exports.ping(), 'pong');
|
||||
// Check that after the addon is loaded with
|
||||
// process.dlopen() a require() call fails.
|
||||
console.log('require:', `./build/${common.buildType}/binding`);
|
||||
const re = /^Error: Module did not self-register\.$/;
|
||||
const re = /^Error: Module did not self-register: '.*[\\/]binding\.node'\.$/;
|
||||
assert.throws(() => require(`./build/${common.buildType}/binding`), re);
|
||||
@@ -2,5 +2,5 @@
|
||||
const common = require('../../common');
|
||||
const assert = require('assert');
|
||||
|
||||
const re = /^Error: Module did not self-register\.$/;
|
||||
const re = /^Error: Module did not self-register: '.*[\\/]binding\.node'\.$/;
|
||||
assert.throws(() => require(`./build/${common.buildType}/binding`), re);
|
||||
Reference in new issue
Block a user