Improved error handling.
This commit is contained in:
parent
6f4ee4c2bf
commit
db9e98f025
1 changed files with 25 additions and 20 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue