Improved error handling.

This commit is contained in:
Martin Edenhofer 2012-10-29 00:47:55 +01:00
parent 6f4ee4c2bf
commit db9e98f025

View file

@ -4,6 +4,7 @@ module RSS
items = Cache.get( cache_key )
return items if items
begin
puts 'fetch rss...'
response = Net::HTTP.get_response( URI.parse(url) )
if response.code.to_s != '200'
@ -25,6 +26,10 @@ module RSS
break item if fetched == limit.to_i
}
Cache.write( cache_key, items, :expires_in => 4.hours )
rescue Exception => e
puts "can't fetch #{url}"
puts e.inspect
end
return items
end