Improve handling of abiword errors

pull/37/head
Peter 'Pita' Martischka 2011-07-24 20:53:28 +01:00
parent 8138c7d15e
commit 358046fd5b
2 changed files with 5 additions and 6 deletions

View File

@ -29,10 +29,10 @@ var queue = async.queue(doConvertTask, 1);
//spawn the abiword process //spawn the abiword process
var abiword = spawn(settings.abiword, ["--plugin", "AbiCommand"]); var abiword = spawn(settings.abiword, ["--plugin", "AbiCommand"]);
//output error messages to stderr //append error messages to the buffer
abiword.stderr.on('data', function (data) abiword.stderr.on('data', function (data)
{ {
console.error("Abiword: " + data); stdoutBuffer += data.toString();
}); });
//throw exceptions if abiword is dieing //throw exceptions if abiword is dieing
@ -57,8 +57,7 @@ function onAbiwordStdout(data)
if(stdoutBuffer.search("AbiWord:>") != -1) if(stdoutBuffer.search("AbiWord:>") != -1)
{ {
//filter the feedback message //filter the feedback message
var lines = stdoutBuffer.split("\n"); var err = stdoutBuffer.search("OK") != -1 ? null : stdoutBuffer;
var err = lines [1] == "OK" ? null : lines[1];
//reset the buffer //reset the buffer
stdoutBuffer = ""; stdoutBuffer = "";

View File

@ -109,9 +109,9 @@ exports.doImport = function(req, res, padId)
} }
], function(err) ], function(err)
{ {
if(err) throw err;
//close the connection //close the connection
res.send("ok"); res.send("ok");
if(err) throw err;
}); });
} }