diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2010-08-24 19:43:14 +0200 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2010-08-24 19:43:14 +0200 |
commit | ea631e1b17c124dc6a990df13414c51e6e0610b6 (patch) | |
tree | e8bbea16abc3881a92071d73c953c2bfa1bde4cc | |
parent | 3ef4b8b3296db0c52e5a7368f673832b80a503f1 (diff) |
hangman plugin: don't fail silently on !hangman
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.
-rw-r--r-- | data/rbot/plugins/games/hangman.rb | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/data/rbot/plugins/games/hangman.rb b/data/rbot/plugins/games/hangman.rb index 7cfd9e69..612b8350 100644 --- a/data/rbot/plugins/games/hangman.rb +++ b/data/rbot/plugins/games/hangman.rb @@ -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 |