Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Raise a better error when memegenerator.net is down

  • Loading branch information...
commit 4e24f0aca076e82e2c22971f6a206a24c68a598b 1 parent c8aa6fc
@drbrain authored
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/meme.rb
View
9 lib/meme.rb
@@ -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
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.