Skip to content

Commit

Permalink
Responds with a nice error if the content type isnt supported
Browse files Browse the repository at this point in the history
  • Loading branch information
garrows committed Jul 14, 2015
1 parent 6dbe7d0 commit 3defed5
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ module.exports = function (_config) {
bufferStream: true
}, function (_error, _size) {
if(_error) {
console.log(_error);
return _callback(_error);
}
image.size = _size;
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}
}
});

Expand Down

0 comments on commit 3defed5

Please sign in to comment.