Skip to content

Commit

Permalink
uncaughtException handler should output to stderr, trace should be op…
Browse files Browse the repository at this point in the history
…t-in with --trace.
  • Loading branch information
mde committed May 22, 2011
1 parent 855be44 commit 8d0862f
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions lib/jake.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,20 @@ var JAKE_VERSION = '0.1.12'
, tasks;

process.addListener('uncaughtException', function (err) {
console.log('jake aborted.');
if (err.stack) {
console.log(err.stack);
var msg;
console.error('jake aborted.');
if (opts.trace && err.stack) {
console.error(err.stack);
}
else {
if (err.stack) {
msg = err.stack.split('\n').slice(0, 2).join('\n');
console.error(msg);
console.error('(See full trace by running task with --trace)');
}
else {
console.error(err.message);
}
}
process.exit(jake.errorCode || 1);
});
Expand Down Expand Up @@ -78,6 +89,7 @@ usage = ''
+ ' -f, --jakefile FILE Use FILE as the Jakefile\n'
+ ' -C, --directory DIRECTORY Change to DIRECTORY before running tasks.\n'
+ ' -T, --tasks Display the tasks, with descriptions, then exit.\n'
+ ' -t, --trace Enable full backtrace.\n'
+ ' -h, --help Outputs help information\n'
+ ' -V, --version Outputs Jake version\n'
+ '';
Expand Down Expand Up @@ -706,6 +718,9 @@ optsReg = [
, { full: 'tasks'
, abbr: 'T'
}
, { full: 'trace'
, abbr: 't'
}
, { full: 'help'
, abbr: 'h'
}
Expand Down

0 comments on commit 8d0862f

Please sign in to comment.