From 36a551ce9a7cd848903fe40c6cca82009f9bd310 Mon Sep 17 00:00:00 2001 From: "Micah Andrew F. Bule" Date: Fri, 22 Jun 2018 07:49:07 +0800 Subject: [PATCH] Fixed error handling --- lib/pdf.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pdf.js b/lib/pdf.js index 3179754..c74d7bb 100644 --- a/lib/pdf.js +++ b/lib/pdf.js @@ -121,7 +121,7 @@ PDF.prototype.exec = function PdfExec (callback) { // Ignore if code has a value of 0 since that means PhantomJS has executed and exited successfully. // Also, as per your script and standards, having a code value of 1 means one can always assume that // an error occured. - if ((typeof code !== 'undefined' && code !== null) && code !== 0) { + if (((typeof code !== 'undefined' && code !== null) && code !== 0) || err) { var error = null if (err) { @@ -134,7 +134,7 @@ PDF.prototype.exec = function PdfExec (callback) { // Append anything caught from the stderr var postfix = stderr.length ? '\n' + Buffer.concat(stderr).toString() : '' - if (postfix) err.message += postfix + if (postfix) error.message += postfix return callback(error) }