Change: error message includes extMessage

This commit is contained in:
anseki 2015-04-25 18:15:35 +09:00
parent 1e7160c6d2
commit 64e65b27d3
3 changed files with 247 additions and 246 deletions

476
README.md

File diff suppressed because it is too large Load diff

View file

@ -222,7 +222,7 @@ function _readlineSync(options) {
}
function readlineExt(options) {
var hostArgs, res = {},
var hostArgs, res = {}, extMessage,
execOptions = {env: process.env, encoding: options.encoding};
if (!extHostPath) {
@ -251,11 +251,12 @@ function readlineExt(options) {
try {
res.input = childProc.execFileSync(extHostPath, hostArgs, execOptions);
} catch (e) { // non-zero exit code
res.error = new Error(DEFAULT_ERR_MSG);
extMessage = e.stderr.trim();
res.error = new Error(DEFAULT_ERR_MSG + (extMessage ? '\n' + extMessage : ''));
res.error.method = 'execFileSync';
res.error.program = extHostPath;
res.error.args = hostArgs;
res.error.extMessage = e.stderr.trim();
res.error.extMessage = extMessage;
res.error.exitCode = e.status;
res.error.code = e.code;
res.error.signal = e.signal;
@ -296,7 +297,7 @@ function _execFileSync(options, execOptions) {
return filepath;
}
var hostArgs, shellPath, shellArgs, res = {}, exitCode,
var hostArgs, shellPath, shellArgs, res = {}, exitCode, extMessage,
pathStdout = getTempfile('readline-sync.stdout'),
pathStderr = getTempfile('readline-sync.stderr'),
pathExit = getTempfile('readline-sync.exit'),
@ -353,12 +354,12 @@ function _execFileSync(options, execOptions) {
'hex', options.encoding) +
decipher.final(options.encoding);
} else {
res.error = new Error(DEFAULT_ERR_MSG);
extMessage = fs.readFileSync(pathStderr, {encoding: options.encoding}).trim();
res.error = new Error(DEFAULT_ERR_MSG + (extMessage ? '\n' + extMessage : ''));
res.error.method = '_execFileSync';
res.error.program = shellPath;
res.error.args = shellArgs;
res.error.extMessage =
fs.readFileSync(pathStderr, {encoding: options.encoding}).trim();
res.error.extMessage = extMessage;
res.error.exitCode = +exitCode;
}

View file

@ -1,6 +1,6 @@
{
"name": "readline-sync",
"version": "1.2.12",
"version": "1.2.13",
"title": "readlineSync",
"description": "Synchronous Readline for interactively running to have a conversation with the user via a console(TTY).",
"keywords": [