joyent/node — pull request #2874 by shigeki (2012-03-05 18:05:01+00:00)
Title: process: Show the detail error message in process.dlopen()

Per discussions in https://github.com/joyent/libuv/issues/286 and https://github.com/joyent/libuv/pull/325 , it is worth while to show the detail error message via uv_dlerror() when requiring of a native module is failed in process.dlopen(). The current error message is static as "Unable to load shared library" regardless of the reason for the error.

For example on Linux, this patch shows the error as below

````
> ./node -e 'require("./test/fixtures/module-loading-error.node")'

module.js:311
throw err;
^
Error: /home/ohtsu/tmp/github/node/test/fixtures/module-loading-error.node: file too short
at Object..node (module.js:474:11)
at Module.load (module.js:350:32)
at Function._load (module.js:308:12)
at Module.require (module.js:356:17)
at require (module.js:372:17)
at Object. (eval at (eval:1:82))
at Object. (eval\1:70)
at Module._compile (module.js:443:26)
at startup (node.js:76:27)
at node.js:555:3
````

And on Windows it does

````
>Release\node.exe -e "require('./test/fixtures/module-loading-error.node')"

module.js:311
throw err;
^
Error: %1 is not a valid Win32 application.
C:\Users\ohtsu\Desktop\shigeki\test\fixtures\module-loading-error.node
at Object..node (module.js:474:11)
at Module.load (module.js:350:32)
at Function._load (module.js:308:12)
at Module.require (module.js:356:17)
at require (module.js:372:17)
at Object. (eval at (eval:1:82))
at Object. (eval:1:70)
at Module._compile (module.js:443:26)
at startup (node.js:76:27)
at node.js:555:3
````