Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Catch error when getting comments from a photo which has been removed…

… from the group
  • Loading branch information...
commit 9d804da6ae1dafcb41229ab772adad57601a7188 1 parent 5836c28
Dave Schweisguth authored
Showing with 15 additions and 11 deletions.
  1. +15 −11 app/models/photo.rb
26 app/models/photo.rb
View
@@ -518,19 +518,23 @@ def update_from_flickr
# the caller is a member. Not clear yet whether this is a bug or intended behavior.
end
- comments_xml = FlickrCredentials.request 'flickr.photos.comments.getList', 'photo_id' => flickrid
- parsed_comments = comments_xml['comments'][0]['comment']
- if ! parsed_comments.blank? # This element is nil if there are no comments and an array if there are
- transaction do
- Comment.where(:photo_id => id).delete_all
- parsed_comments.each do |comment_xml|
- self.comments.create!(
- :flickrid => comment_xml['author'],
- :username => comment_xml['authorname'],
- :comment_text => comment_xml['content'],
- :commented_at => Time.at(comment_xml['datecreate'].to_i).getutc)
+ begin
+ comments_xml = FlickrCredentials.request 'flickr.photos.comments.getList', 'photo_id' => flickrid
+ parsed_comments = comments_xml['comments'][0]['comment']
+ if ! parsed_comments.blank? # This element is nil if there are no comments and an array if there are
+ transaction do
+ Comment.where(:photo_id => id).delete_all
+ parsed_comments.each do |comment_xml|
+ self.comments.create!(
+ :flickrid => comment_xml['author'],
+ :username => comment_xml['authorname'],
+ :comment_text => comment_xml['content'],
+ :commented_at => Time.at(comment_xml['datecreate'].to_i).getutc)
+ end
end
end
+ rescue FlickrCredentials::FlickrRequestFailedError
+ # This happens when a photo has been removed from the group.
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.