Skip to content

Commit

Permalink
Merge pull request riyadhalnur#7 from orechova/master
Browse files Browse the repository at this point in the history
Handle image loading failure (empty body or statusCode other than 200)
  • Loading branch information
riyadhalnur committed Feb 4, 2016
2 parents 0b6ba64 + 27d1ff8 commit f9287c9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ var base64encoder = function (url, options, callback) {

if (body && res.statusCode === 200) {
return encoder(body, options);
} else {
if (!body) { return callback('Image loading error - empty body'); }
else { return callback('Image loading error - ' + res.statusCode); }
}
});
}
Expand All @@ -58,4 +61,4 @@ var base64decoder = function (imageBuffer, options, callback) {
module.exports = {
base64encoder: base64encoder,
base64decoder: base64decoder
};
};
13 changes: 13 additions & 0 deletions test/tests.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f9287c9

Please sign in to comment.