diff options
author | Fedor Indutny <fedor.indutny@gmail.com> | 2014-01-05 01:50:54 +0400 |
---|---|---|
committer | Fedor Indutny <fedor.indutny@gmail.com> | 2014-01-09 00:00:30 +0400 |
commit | 730e511b3598c5fea416da680060c83ed2751a25 (patch) | |
tree | f26843e56aac473ed630e8c2e17e919278d75b54 /lib/child_process.js | |
parent | 4800310f6aa5dc9dcb564aff7428a2bea6f88d88 (diff) | |
download | nodejs-730e511b3598c5fea416da680060c83ed2751a25.tar.gz nodejs-730e511b3598c5fea416da680060c83ed2751a25.tar.bz2 nodejs-730e511b3598c5fea416da680060c83ed2751a25.zip |
child_process: better error reporting for exec
Report path to executable and argv on error, stderr is not enough in
many cases.
fix #6796
Diffstat (limited to 'lib/child_process.js')
-rw-r--r-- | lib/child_process.js | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/child_process.js b/lib/child_process.js index bcbd08d6c..8afd7b225 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -664,7 +664,7 @@ exports.execFile = function(file /* args, options, callback */) { var exited = false; var timeoutId; - var ex; + var ex = null; function exithandler(code, signal) { if (exited) return; @@ -689,16 +689,25 @@ exports.execFile = function(file /* args, options, callback */) { } if (ex) { - callback(ex, stdout, stderr); + // Will be handled later } else if (code === 0 && signal === null) { callback(null, stdout, stderr); - } else { - ex = new Error('Command failed: ' + stderr); + return; + } + + var cmd = file; + if (args.length !== 0) + cmd += ' ' + args.join(' '); + + if (!ex) { + ex = new Error('Command failed: ' + cmd + '\n' + stderr); ex.killed = child.killed || killed; ex.code = code < 0 ? uv.errname(code) : code; ex.signal = signal; - callback(ex, stdout, stderr); } + + ex.cmd = cmd; + callback(ex, stdout, stderr); } function errorhandler(e) { |