Print friendly error message when main module is ENOENT
This commit is contained in:
parent
c321e9893d
commit
5890272538
12
src/node.js
12
src/node.js
@ -348,7 +348,17 @@ var module = (function () {
|
|||||||
exports.runMain = function () {
|
exports.runMain = function () {
|
||||||
// Load the main module--the command line argument.
|
// Load the main module--the command line argument.
|
||||||
process.mainModule = new Module(".");
|
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;
|
return exports;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user