diff --git a/lib/events.js b/lib/events.js index d41608deee..ea8f7aa628 100644 --- a/lib/events.js +++ b/lib/events.js @@ -9,7 +9,7 @@ EventEmitter.prototype.emit = function (type) { (isArray(this._events.error) && !this._events.error.length)) { if (arguments[1] instanceof Error) { - throw arguments[1]; + throw arguments[1]; // Unhandled 'error' event } else { throw new Error("Uncaught, unspecified 'error' event."); } diff --git a/src/node.cc b/src/node.cc index 8f13c64b64..004fa99b03 100644 --- a/src/node.cc +++ b/src/node.cc @@ -986,7 +986,15 @@ static void ReportException(TryCatch &try_catch, bool show_line) { if (trace.length() > 0) { fprintf(stderr, "%s\n", *trace); + } else { + // this really only happens for RangeErrors, since they're the only + // kind that won't have all this info in the trace. + Local er = try_catch.Exception(); + String::Utf8Value msg(!er->IsObject() ? er->ToString() + : er->ToObject()->Get(String::New("message"))->ToString()); + fprintf(stderr, "%s\n", *msg); } + fflush(stderr); } diff --git a/src/node.js b/src/node.js index bdc208455d..7d177eb6ce 100644 --- a/src/node.js +++ b/src/node.js @@ -47,7 +47,7 @@ process._tickCallback = function () { if (i+1 < l) { process._needTickCallback(); } - throw e; + throw e; // process.nextTick error, or 'error' event on first tick } nextTickQueue.splice(0, l); @@ -99,7 +99,7 @@ var module = (function () { var m = new Module(id); internalModuleCache[id] = m; var e = m._compile(natives[id], id); - if (e) throw e; + if (e) throw e; // error compiling native module return m; } diff --git a/test/message/undefined_reference_in_new_context.out b/test/message/undefined_reference_in_new_context.out index e9a5675828..6d3ab75fff 100644 --- a/test/message/undefined_reference_in_new_context.out +++ b/test/message/undefined_reference_in_new_context.out @@ -1,7 +1,7 @@ before node.js:* - throw e; + throw e; // process.nextTick error, or 'error' event on first tick ^ ReferenceError: foo is not defined at evalmachine.:*