Skip to content
Snippets Groups Projects
Unverified Commit 17d82833 authored by Diego Sampaio's avatar Diego Sampaio
Browse files

Fix error handling for non-valid avatar URL

parent 83257e54
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,7 @@ RocketChat.setUserAvatar = function(user, dataURI, contentType, service) { ...@@ -10,7 +10,7 @@ RocketChat.setUserAvatar = function(user, dataURI, contentType, service) {
try { try {
result = HTTP.get(dataURI, { npmRequestOptions: {encoding: 'binary'} }); result = HTTP.get(dataURI, { npmRequestOptions: {encoding: 'binary'} });
} catch (error) { } 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); 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 }); 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 });
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment