]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
hangman plugin: don't fail silently on !hangman
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Tue, 24 Aug 2010 17:43:14 +0000 (19:43 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Tue, 24 Aug 2010 17:43:14 +0000 (19:43 +0200)
If the random generation site failed for any reason (eg. by returning a
non-2xx page), starting a hangman game would fail silently.

Catch this case and announce the failure.

data/rbot/plugins/games/hangman.rb

index 7cfd9e69759bf29de309112356899d7b6f2e655e..612b83501e68374053193782722e8c475d9b434e 100644 (file)
@@ -16,6 +16,7 @@ module RandomWord
 
   def self.get(count=1)
     res = Net::HTTP.post_form(URI.parse(SITE), {'numwords' => count})
+    raise _("random word generator site failed with #{res.code} - #{res.message}") unless Net::HTTPSuccess === res
     words = res.body.scan(%r{<a.*?\?w=(.*?)\n}).flatten
 
     count == 1 ? words.first : words