Making use of console.error

NodeJS outputs errors to stderr. Making use of console.error(...) instead of console.log(...) makes node-source-map-support compatible with IDEs like Webstorm to get stack traces.
This commit is contained in:
Clément Bourgeois 2014-11-03 19:39:43 +01:00
parent 3b154ff43e
commit c4435f6b5c

View File

@ -331,11 +331,11 @@ function getErrorSource(error) {
// Mimic node's stack trace printing when an exception escapes the process
function handleUncaughtExceptions(error) {
if (!error || !error.stack) {
console.log('Uncaught exception:', error);
console.error('Uncaught exception:', error);
} else {
var source = getErrorSource(error);
if (source !== null) console.log(source);
console.log(error.stack);
if (source !== null) console.error(source);
console.error(error.stack);
}
process.exit(1);
}