@@ -482,12 +482,9 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
482482 mp = dlib->GetSavedModuleFromGlobalHandleMap ();
483483 if (mp == nullptr || mp->nm_context_register_func == nullptr ) {
484484 dlib->Close ();
485- char errmsg[1024 ];
486- snprintf (errmsg,
487- sizeof (errmsg),
488- " Module did not self-register: '%s'." ,
489- *filename);
490- THROW_ERR_DLOPEN_FAILED (env, errmsg);
485+ THROW_ERR_DLOPEN_FAILED (
486+ env, " Module did not self-register: '%s'." ,
487+ *filename);
491488 return false ;
492489 }
493490 }
@@ -502,23 +499,21 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
502499 callback (exports, module , context);
503500 return true ;
504501 }
505- char errmsg[1024 ];
506- snprintf (errmsg,
507- sizeof (errmsg),
508- " The module '%s'"
509- " \n was compiled against a different Node.js version using"
510- " \n NODE_MODULE_VERSION %d. This version of Node.js requires"
511- " \n NODE_MODULE_VERSION %d. Please try re-compiling or "
512- " re-installing\n the module (for instance, using `npm rebuild` "
513- " or `npm install`)." ,
514- *filename,
515- mp->nm_version ,
516- NODE_MODULE_VERSION);
517502
518503 // NOTE: `mp` is allocated inside of the shared library's memory, calling
519504 // `dlclose` will deallocate it
520505 dlib->Close ();
521- THROW_ERR_DLOPEN_FAILED (env, errmsg);
506+ THROW_ERR_DLOPEN_FAILED (
507+ env,
508+ " The module '%s'"
509+ " \n was compiled against a different Node.js version using"
510+ " \n NODE_MODULE_VERSION %d. This version of Node.js requires"
511+ " \n NODE_MODULE_VERSION %d. Please try re-compiling or "
512+ " re-installing\n the module (for instance, using `npm rebuild` "
513+ " or `npm install`)." ,
514+ *filename,
515+ mp->nm_version ,
516+ NODE_MODULE_VERSION);
522517 return false ;
523518 }
524519 CHECK_EQ (mp->nm_flags & NM_F_BUILTIN, 0 );
@@ -631,12 +626,9 @@ void GetLinkedBinding(const FunctionCallbackInfo<Value>& args) {
631626 mod = FindModule (modlist_linked, name, NM_F_LINKED);
632627
633628 if (mod == nullptr ) {
634- char errmsg[1024 ];
635- snprintf (errmsg,
636- sizeof (errmsg),
637- " No such module was linked: %s" ,
638- *module_name_v);
639- return THROW_ERR_INVALID_MODULE (env, errmsg);
629+ return THROW_ERR_INVALID_MODULE (env,
630+ " No such module was linked: %s" ,
631+ *module_name_v);
640632 }
641633
642634 Local<Object> module = Object::New (env->isolate ());
0 commit comments