From 3defed529a8684b1046373a8811a182b15eac5e7 Mon Sep 17 00:00:00 2001 From: Glen Arrowsmith Date: Tue, 14 Jul 2015 16:24:35 +1000 Subject: [PATCH] Responds with a nice error if the content type isnt supported --- src/index.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 083a4ee..5260172 100644 --- a/src/index.js +++ b/src/index.js @@ -132,7 +132,6 @@ module.exports = function (_config) { bufferStream: true }, function (_error, _size) { if(_error) { - console.log(_error); return _callback(_error); } image.size = _size; @@ -217,6 +216,8 @@ module.exports = function (_config) { ], function (_error) { + if (_error) return _manipulationDoneCallback(_error); + //Stream it back. gmImage.autoOrient().stream(function (_error, _stdout, _stderr) { if(_error) { @@ -243,8 +244,16 @@ module.exports = function (_config) { ], function (_error) { if(_error) { - console.log('error', _error); - _next(_error); + if (_error.message.indexOf('no decode delegate') !== -1) { + _res.status(415).send({ + error: { + status: 415, + message: 'Unsupported file format' + } + }); + } else { + _next(_error); + } } });