kylejginavan/youtube_it — Issue #37: FeedParser exception handling
Author: tokland
Created: 2011-12-01 08:10:11+00:00
State: open

While testing the gem I had a network problem and I was surprised to see that the *videos_by* continued "working", but returning empty objects. I checked the code and the problem seems to be here:

class FeedParser #:nodoc:
def initialize(content)
@content = open(content).read
rescue OpenURI::HTTPError => e
raise OpenURI::HTTPError.new(e.io.status[0],e)
rescue
@content = content
end

I don't understand the details of the first rescue but I guess for some reason it must be important to re-raise with different parameters. But the second rescue makes no sense, assign content (a url, why is it called content?) to @content (the body response)? why don't leave the method raise the exception and let the caller decide how to handle it?