diff options
author | 2016-08-12 18:34:42 +0200 | |
---|---|---|
committer | 2016-08-13 20:23:45 +0200 | |
commit | a3c12a104f9293ab3ce9b8cf440f2f0636fb46fa (patch) | |
tree | bc1064ee3257fbe94487b8f572789aca65dee7c9 | |
parent | !meta -v: fix project expansion. (diff) | |
download | rbot-gentoo-a3c12a104f9293ab3ce9b8cf440f2f0636fb46fa.tar.gz rbot-gentoo-a3c12a104f9293ab3ce9b8cf440f2f0636fb46fa.tar.bz2 rbot-gentoo-a3c12a104f9293ab3ce9b8cf440f2f0636fb46fa.zip |
!*dep: Fix handling errors
-rw-r--r-- | gentoo-data.rb | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/gentoo-data.rb b/gentoo-data.rb index 792244a..e37d376 100644 --- a/gentoo-data.rb +++ b/gentoo-data.rb @@ -311,18 +311,20 @@ class GentooPlugin < Plugin # Watch out for network problems begin - packages = @bot.httputil.get(url+cp) + resp = @bot.httputil.get_response(url+cp) + if Net::HTTPNotFound === resp + packages = '' + elsif not Net::HTTPOK === resp + m.reply "HTTP error: #{resp}" + return + else + packages = resp.body.split("\n") + end rescue ::Exception => e - m.reply e.message + m.reply "Error: #{e.message}" return end - # 404 error => nil response - packages = '' if packages.nil? - - # Only then can we split it - packages = packages.split("\n") - if packages.length == 0 m.reply "No packages have a reverse #{type} on #{cp}." elsif packages.join(' ').length > 400 |