From 7ddf1f569a809c746874d85527915ac68bc0510c Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sun, 20 Sep 2009 18:03:55 +0200 Subject: [PATCH] Improve error message for requiring system modules. --- src/node.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/node.js b/src/node.js index b65b9ccef0..257c5e8bcf 100644 --- a/src/node.js +++ b/src/node.js @@ -179,7 +179,7 @@ node.Module.cache = {}; if (fullPath) { retrieveFromCache(loadPromise, fullPath, parent); } else { - loadPromise.emitError(); + loadPromise.emitError(new Error("Cannot find module '" + requestedPath + "'")); } }); @@ -220,8 +220,8 @@ node.Module.prototype.loadObject = function (loadPromise) { node.dlopen(self.filename, self.target); // FIXME synchronus loadPromise.emitSuccess(self.target); } else { - node.stdio.writeError("Error reading " + self.filename + "\n"); - loadPromise.emitError(); + node.error("Error reading " + self.filename + "\n"); + loadPromise.emitError(new Error("Error reading " + self.filename)); node.exit(1); } }); @@ -232,7 +232,8 @@ node.Module.prototype.loadScript = function (loadPromise) { var catPromise = node.cat(self.filename); catPromise.addErrback(function () { - loadPromise.emitError(new Error("Error reading " + self.filename + "\n")); + loadPromise.emitError(new Error("Error reading " + self.filename)); + node.exit(1); }); catPromise.addCallback(function (content) {