From 4bbac2831aeac27f0e95d59ca5df6bb5dd27753c Mon Sep 17 00:00:00 2001 From: hrovira Date: Sat, 15 Oct 2016 14:38:41 -0700 Subject: [PATCH] resolving error handling issues. avoid duplicate invocation of callback. avoid invocation of callback on standard error out. both situations result in runtime errors that cannot be recovered from --- lib/info.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/info.js b/lib/info.js index 71bd65f..84b57e7 100644 --- a/lib/info.js +++ b/lib/info.js @@ -18,8 +18,7 @@ module.exports.process = function(pdf_path, callback) { stderr.setEncoding('utf8'); stderr.on('data', function(data) { - console.log('data ' + data) - return callback(data, null); + console.warn('pdf-to-text', 'info.process', '[stderr data]', data); }); // buffer the stdout output @@ -28,11 +27,8 @@ module.exports.process = function(pdf_path, callback) { }); stdout.on('close', function(code) { - if (code) { - callback('pdfinfo end with code ' + code, null); - } - output = convertOutputToObject(output); - callback(null, output); + if (code) return callback('pdfinfo end with code ' + code, null); + callback(null, convertOutputToObject(output)); }); }; /**