modules: fix error message for native add-ons without entry points

Trying to load an add-on without "init" or "modname_module" symbols would raise
an "Out of memory" exception. Let's improve that error message.
This commit is contained in:
Ben Noordhuis 2011-11-27 22:38:54 +01:00
parent e85a95dfa3
commit 216019b72d

View File

@ -1594,9 +1594,14 @@ Handle<Value> DLOpen(const v8::Arguments& args) {
err = uv_dlsym(lib, "init", reinterpret_cast<void**>(&mod->register_func));
if (err.code != UV_OK) {
uv_dlclose(lib);
Local<Value> exception = Exception::Error(
String::New("Out of memory."));
return ThrowException(exception);
const char* message;
if (err.code == UV_ENOENT)
message = "Module entry point not found.";
else
message = "Out of memory.";
return ThrowException(Exception::Error(String::New(message)));
}
/* End Compatibility hack */
}