diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2010-11-22 00:58:47 +0300 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2010-11-22 00:58:47 +0300 |
commit | 58902725387a87e363410519f9afb865c2c3300d (patch) | |
tree | 36f1ae04e6a4f8319ec5095b45d7ead173b879e6 /src | |
parent | c321e9893d9eabefb125d9e4efa964603fed9dfe (diff) |
Print friendly error message when main module is ENOENT
Diffstat (limited to 'src')
-rw-r--r-- | src/node.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/node.js b/src/node.js index 31e7da4fa3c..aba2eb70445 100644 --- a/src/node.js +++ b/src/node.js @@ -348,7 +348,17 @@ var module = (function () { exports.runMain = function () { // Load the main module--the command line argument. process.mainModule = new Module("."); - process.mainModule.load(process.argv[1]); + try { + process.mainModule.load(process.argv[1]); + } catch (e) { + if (!constants) constants = process.binding("constants"); + if (e.errno == constants.ENOENT) { + console.error("Cannot load '%s'", process.argv[1]); + process.exit(1); + } else { + throw e; + } + } }; return exports; |