From 8a52fb7aebcde0baa5682a19cdb1d03dfa63201f Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 1 Jul 2010 11:10:22 -0700 Subject: [PATCH] Revert "Fix 'uncaughtException' for top level exceptions" This reverts commit 8f8dcf8ed63b19a6c20915e12af83a3ad792f1d2. --- lib/module.js | 6 ++---- src/node.cc | 5 +++-- src/node.js | 2 +- test/simple/test-error-reporting.js | 8 ++++---- test/simple/test-uncaught-exception.js | 13 ------------- 5 files changed, 10 insertions(+), 24 deletions(-) delete mode 100644 test/simple/test-uncaught-exception.js diff --git a/lib/module.js b/lib/module.js index 1a1b01bbd9..b9067d24af 100644 --- a/lib/module.js +++ b/lib/module.js @@ -437,11 +437,9 @@ Module.prototype._waitChildrenLoad = function (callback) { // bootstrap main module. -exports.runMain = function (filename) { +exports.runMain = function () { // Load the main module--the command line argument. process.mainModule = new Module("."); - process.mainModule.load(filename, function (err) { - if (err) throw err; - }); + process.mainModule.loadSync(process.argv[1]); } diff --git a/src/node.cc b/src/node.cc index f1e47ef024..5aa37120da 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1805,8 +1805,9 @@ static void Load(int argc, char *argv[]) { f->Call(global, 1, args); - if (try_catch.HasCaught()) { - FatalException(try_catch); + if (try_catch.HasCaught()) { + ReportException(try_catch, true); + exit(11); } } diff --git a/src/node.js b/src/node.js index b3dc069dd3..97b1f1b9df 100644 --- a/src/node.js +++ b/src/node.js @@ -239,7 +239,7 @@ if (process.argv[1]) { process.argv[1] = path.join(cwd, process.argv[1]); } - module.runMain(process.argv[1]); + module.runMain(); } else { // No arguments, run the repl var repl = module.requireNative('repl'); diff --git a/test/simple/test-error-reporting.js b/test/simple/test-error-reporting.js index c283e7bbf0..46c8982c23 100644 --- a/test/simple/test-error-reporting.js +++ b/test/simple/test-error-reporting.js @@ -33,14 +33,14 @@ errExec('throws_error.js', function (err, stdout, stderr) { }); -// Trying to JSON.parse(undefined) in nextTick -errExec('throws_error3.js', function (err, stdout, stderr) { +// Trying to JSON.parse(undefined) +errExec('throws_error2.js', function (err, stdout, stderr) { assert.ok(/JSON/.test(stderr)); }); -// Trying to JSON.parse(undefined) -errExec('throws_error2.js', function (err, stdout, stderr) { +// Trying to JSON.parse(undefined) in nextTick +errExec('throws_error3.js', function (err, stdout, stderr) { assert.ok(/JSON/.test(stderr)); }); diff --git a/test/simple/test-uncaught-exception.js b/test/simple/test-uncaught-exception.js deleted file mode 100644 index 739d9944bc..0000000000 --- a/test/simple/test-uncaught-exception.js +++ /dev/null @@ -1,13 +0,0 @@ -require('../common') - -process.addListener('uncaughtException', function (err) { - puts('Caught exception: ' + err); -}); - -setTimeout(function () { - puts('This will still run.'); -}, 500); - -// Intentionally cause an exception, but don't catch it. -nonexistentFunc(); -puts('This will not run.');