Skip to content

Commit

Permalink
Raise a better error when memegenerator.net is down
Browse files Browse the repository at this point in the history
  • Loading branch information
drbrain committed Apr 13, 2011
1 parent c8aa6fc commit 4e24f0a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/meme.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def self.run argv = ARGV
rescue SystemExit
raise
rescue Exception => e
puts e.backtrace.join "\n\t" if $DEBUG
abort "ERROR: #{e.message} (#{e.class})"
end

Expand Down Expand Up @@ -216,8 +217,12 @@ def generate *args
res = http.request get
end

doc = Nokogiri.HTML res.body
doc.css("a[href=\"#{location}\"] img").first['src']
if Net::HTTPSuccess === res then
doc = Nokogiri.HTML res.body
doc.css("a[href=\"#{location}\"] img").first['src']
else
raise Error, "memegenerator.net appears to be down, got #{res.code}"
end
end

def fetch link
Expand Down

1 comment on commit 4e24f0a

@ajskateboarder
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait its all ruby?

always has been

Please sign in to comment.