Fix exception output for module load exceptions
So instead of: node.js:201 throw e; // process.nextTick error, or 'error' event on first tick ^ You will now see: path/to/foo.js:1 throw new Error('bar'); ^ This is a sub-set of isaacs patch here: https://github.com/joyent/node/issues/3235 The difference is that this patch purely adresses the exception output, but does not try to make any behavior changes / improvements.
This commit is contained in:
parent
814033365b
commit
bf9d8e9214
@ -304,11 +304,16 @@ Module._load = function(request, parent, isMain) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Module._cache[filename] = module;
|
Module._cache[filename] = module;
|
||||||
|
|
||||||
|
var hadException = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
module.load(filename);
|
module.load(filename);
|
||||||
} catch (err) {
|
hadException = false;
|
||||||
delete Module._cache[filename];
|
} finally {
|
||||||
throw err;
|
if (hadException) {
|
||||||
|
delete Module._cache[filename];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return module.exports;
|
return module.exports;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
before
|
before
|
||||||
|
|
||||||
module.js:311
|
*test*message*stack_overflow.js:31
|
||||||
throw err;
|
function stackOverflow() {
|
||||||
^
|
^
|
||||||
RangeError: Maximum call stack size exceeded
|
RangeError: Maximum call stack size exceeded
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
before
|
before
|
||||||
|
|
||||||
module.js:311
|
*test*message*throw_custom_error.js:31
|
||||||
throw err;
|
throw { name: 'MyCustomError', message: 'This is a custom message' };
|
||||||
^
|
^
|
||||||
MyCustomError: This is a custom message
|
MyCustomError: This is a custom message
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
before
|
before
|
||||||
|
|
||||||
module.js:311
|
*/test/message/throw_non_error.js:31
|
||||||
throw err;
|
throw { foo: 'bar' };
|
||||||
^
|
^
|
||||||
[object Object]
|
[object Object]
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
before
|
before
|
||||||
|
|
||||||
module.js:311
|
*test*message*undefined_reference_in_new_context.js:34
|
||||||
throw err;
|
script.runInNewContext();
|
||||||
^
|
^
|
||||||
ReferenceError: foo is not defined
|
ReferenceError: foo is not defined
|
||||||
at evalmachine.<anonymous>:*
|
at evalmachine.<anonymous>:*
|
||||||
at Object.<anonymous> (*test*message*undefined_reference_in_new_context.js:*)
|
at Object.<anonymous> (*test*message*undefined_reference_in_new_context.js:*)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user