From 358046fd5bd367714f746f23bcbab389514e5426 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Sun, 24 Jul 2011 20:53:28 +0100 Subject: [PATCH] Improve handling of abiword errors --- node/Abiword.js | 7 +++---- node/ImportHandler.js | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/node/Abiword.js b/node/Abiword.js index 4e70d3fb..dd9658bc 100644 --- a/node/Abiword.js +++ b/node/Abiword.js @@ -29,10 +29,10 @@ var queue = async.queue(doConvertTask, 1); //spawn the abiword process var abiword = spawn(settings.abiword, ["--plugin", "AbiCommand"]); -//output error messages to stderr +//append error messages to the buffer abiword.stderr.on('data', function (data) { - console.error("Abiword: " + data); + stdoutBuffer += data.toString(); }); //throw exceptions if abiword is dieing @@ -57,8 +57,7 @@ function onAbiwordStdout(data) if(stdoutBuffer.search("AbiWord:>") != -1) { //filter the feedback message - var lines = stdoutBuffer.split("\n"); - var err = lines [1] == "OK" ? null : lines[1]; + var err = stdoutBuffer.search("OK") != -1 ? null : stdoutBuffer; //reset the buffer stdoutBuffer = ""; diff --git a/node/ImportHandler.js b/node/ImportHandler.js index c7e29483..4d60a920 100644 --- a/node/ImportHandler.js +++ b/node/ImportHandler.js @@ -109,9 +109,9 @@ exports.doImport = function(req, res, padId) } ], function(err) { + if(err) throw err; + //close the connection res.send("ok"); - - if(err) throw err; }); }