Skip to content

Commit

Permalink
Merge pull request #6972 from RocketChat/fix-avatar-from-invalid-url
Browse files Browse the repository at this point in the history
[FIX] Fix error handling for non-valid avatar URL
  • Loading branch information
rodrigok authored May 17, 2017
2 parents a984d1e + 314a158 commit c7d11b6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/rocketchat-lib/server/functions/setUserAvatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RocketChat.setUserAvatar = function(user, dataURI, contentType, service) {
try {
result = HTTP.get(dataURI, { npmRequestOptions: {encoding: 'binary'} });
} catch (error) {
if (error.response.statusCode !== 404) {
if (!error.response || error.response.statusCode !== 404) {
console.log(`Error while handling the setting of the avatar from a url (${ dataURI }) for ${ user.username }:`, error);
throw new Meteor.Error('error-avatar-url-handling', `Error while handling avatar setting from a URL (${ dataURI }) for ${ user.username }`, { function: 'RocketChat.setUserAvatar', url: dataURI, username: user.username });
}
Expand Down

0 comments on commit c7d11b6

Please sign in to comment.