diff options
author | Stephen Whitmore <sww@eight45.net> | 2017-12-28 11:41:15 -0800 |
---|---|---|
committer | Stephen Whitmore <sww@eight45.net> | 2017-12-28 11:41:15 -0800 |
commit | a1fdd6f43395d2a208100cc07a2769a1b684bedf (patch) | |
tree | 33276980176fdf1550dac2c24f9820a231b437e9 /lib | |
parent | c5a95cc1ebe6dd3a4d572220f5cd60c31381de97 (diff) | |
download | patchfoo-a1fdd6f43395d2a208100cc07a2769a1b684bedf.tar.gz patchfoo-a1fdd6f43395d2a208100cc07a2769a1b684bedf.zip |
fix: fail gracefully on jpeg rotation exception
Diffstat (limited to 'lib')
-rw-r--r-- | lib/serve.js | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/serve.js b/lib/serve.js index 76b3a8c..0c1ede8 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -1210,15 +1210,20 @@ Serve.prototype.image = function (path) { if (err) return heresTheData(err) buffer = Buffer.concat(buffer) - jpeg.rotate(buffer, {}, function (err, rotatedBuffer, orientation) { - if (!err) buffer = rotatedBuffer + try { + jpeg.rotate(buffer, {}, function (err, rotatedBuffer, orientation) { + if (!err) buffer = rotatedBuffer - heresTheData(null, buffer) - pull( - pull.once(buffer), - self.respondSink() - ) - }) + heresTheData(null, buffer) + pull( + pull.once(buffer), + self.respondSink() + ) + }) + } catch (err) { + console.trace(err) + self.respond(500, err.message || err) + } } done(function (err, data, type) { |