Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 1 changed file with 15 additions and 11 deletions. Show diff stats Hide diff stats

  1. +15 11 app/models/photo.rb
26 app/models/photo.rb
@@ -518,19 +518,23 @@ def update_from_flickr
518 518 # the caller is a member. Not clear yet whether this is a bug or intended behavior.
519 519 end
520 520
521   - comments_xml = FlickrCredentials.request 'flickr.photos.comments.getList', 'photo_id' => flickrid
522   - parsed_comments = comments_xml['comments'][0]['comment']
523   - if ! parsed_comments.blank? # This element is nil if there are no comments and an array if there are
524   - transaction do
525   - Comment.where(:photo_id => id).delete_all
526   - parsed_comments.each do |comment_xml|
527   - self.comments.create!(
528   - :flickrid => comment_xml['author'],
529   - :username => comment_xml['authorname'],
530   - :comment_text => comment_xml['content'],
531   - :commented_at => Time.at(comment_xml['datecreate'].to_i).getutc)
  521 + begin
  522 + comments_xml = FlickrCredentials.request 'flickr.photos.comments.getList', 'photo_id' => flickrid
  523 + parsed_comments = comments_xml['comments'][0]['comment']
  524 + if ! parsed_comments.blank? # This element is nil if there are no comments and an array if there are
  525 + transaction do
  526 + Comment.where(:photo_id => id).delete_all
  527 + parsed_comments.each do |comment_xml|
  528 + self.comments.create!(
  529 + :flickrid => comment_xml['author'],
  530 + :username => comment_xml['authorname'],
  531 + :comment_text => comment_xml['content'],
  532 + :commented_at => Time.at(comment_xml['datecreate'].to_i).getutc)
  533 + end
532 534 end
533 535 end
  536 + rescue FlickrCredentials::FlickrRequestFailedError
  537 + # This happens when a photo has been removed from the group.
534 538 end
535 539
536 540 end

0 comments on commit 9d804da

Please sign in to comment.
Something went wrong with that request. Please try again.