Commit 7fe595f02515b365abde342489c479764b3741c6

Authored by Daniela Feitosa
2 parents be6e8532 30bcf289

Merge commit 'refs/merge-requests/14' of git://gitorious.org/noosfero/noosfero i…

…nto merge-requests/14
lib/feed_handler.rb
... ... @@ -65,7 +65,12 @@ class FeedHandler
65 65 if container.update_errors > FeedHandler.max_errors
66 66 container.enabled = false
67 67 end
68   - container.finish_fetch
  68 + begin
  69 + container.finish_fetch
  70 + rescue Exception => finish_fetch_exception
  71 + RAILS_DEFAULT_LOGGER.warn("Unable to finish fetch from %s ID %d\n%s" % [container.class.name, container.id, finish_fetch_exception.to_s])
  72 + RAILS_DEFAULT_LOGGER.warn("Backtrace:\n%s" % finish_fetch_exception.backtrace.join("\n"))
  73 + end
69 74 end
70 75 end
71 76  
... ...
test/unit/feed_handler_test.rb
... ... @@ -114,4 +114,11 @@ class FeedHandlerTest < Test::Unit::TestCase
114 114 end
115 115 end
116 116  
  117 + should 'not crash even when finish fetch fails' do
  118 + container.stubs(:finish_fetch).raises(Exception.new("crash"))
  119 + assert_nothing_raised do
  120 + handler.process(container)
  121 + end
  122 + end
  123 +
117 124 end
... ...