From ee13b4bf75b05bf4814deffdfc9609ce7fa8922a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Wed, 28 Jan 2015 12:22:26 +0100 Subject: [PATCH] Improve error message when imagemagick is not installed --- lib/utils/images.js | 9 ++++++++- lib/utils/page.js | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/utils/images.js b/lib/utils/images.js index 5a3992734..5c2db694d 100644 --- a/lib/utils/images.js +++ b/lib/utils/images.js @@ -18,7 +18,14 @@ var convert = function(source, dest, options) { if (options.resize) img = img.resize(options.resize.w, options.resize.h); img.noProfile() - .write(dest, d.makeNodeResolver()); + .write(dest, function(err) { + if (!err) return d.resolve(); + + if (err.code == "ENOENT") { + err = new Error("Need to install 'ImageMagick'"); + } + d.reject(err); + }); return d.promise; }; diff --git a/lib/utils/page.js b/lib/utils/page.js index e526afb39..fa333f28a 100644 --- a/lib/utils/page.js +++ b/lib/utils/page.js @@ -155,8 +155,9 @@ function convertImages(images, options) { return imgUtils.convert(imgin, imgout) .then(function() { options.book.log.debug.ok(); - }, function() { + }, function(err) { options.book.log.debug.fail(); + throw err; }); }); }, Q());