diff options
author | Jeremy Apthorp <nornagon@nornagon.net> | 2019-10-26 00:52:13 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-11-19 18:03:55 +0300 |
commit | 4f434187ff06cc8ac9e2022e65d6f6bf2fb8a19e (patch) | |
tree | 202bedfd5c4c2e6430c2c8e37921a30d52b707db | |
parent | 7cecac669f05f36016c684dcee381cf21ab188d2 (diff) |
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>
-rw-r--r-- | src/node_binding.cc | 7 | ||||
-rw-r--r-- | test/addons/dlopen-ping-pong/test-worker.js | 3 | ||||
-rw-r--r-- | test/addons/dlopen-ping-pong/test.js | 2 | ||||
-rw-r--r-- | test/addons/not-a-binding/test.js | 2 |
4 files changed, 10 insertions, 4 deletions
diff --git a/src/node_binding.cc b/src/node_binding.cc index d083c64d102..f57ddb54b62 100644 --- a/src/node_binding.cc +++ b/src/node_binding.cc @@ -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; } } diff --git a/test/addons/dlopen-ping-pong/test-worker.js b/test/addons/dlopen-ping-pong/test-worker.js index feba6aa5eb0..d24bd2df805 100644 --- a/test/addons/dlopen-ping-pong/test-worker.js +++ b/test/addons/dlopen-ping-pong/test-worker.js @@ -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}'.`); })); diff --git a/test/addons/dlopen-ping-pong/test.js b/test/addons/dlopen-ping-pong/test.js index c5b8c16493f..c3461d8bd26 100644 --- a/test/addons/dlopen-ping-pong/test.js +++ b/test/addons/dlopen-ping-pong/test.js @@ -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); diff --git a/test/addons/not-a-binding/test.js b/test/addons/not-a-binding/test.js index a0ce2d0629a..4b4e7150ebb 100644 --- a/test/addons/not-a-binding/test.js +++ b/test/addons/not-a-binding/test.js @@ -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); |