aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2016-08-12 18:34:42 +0200
committerMichał Górny <mgorny@gentoo.org>2016-08-13 20:23:45 +0200
commita3c12a104f9293ab3ce9b8cf440f2f0636fb46fa (patch)
treebc1064ee3257fbe94487b8f572789aca65dee7c9
parent!meta -v: fix project expansion. (diff)
downloadrbot-gentoo-a3c12a104f9293ab3ce9b8cf440f2f0636fb46fa.tar.gz
rbot-gentoo-a3c12a104f9293ab3ce9b8cf440f2f0636fb46fa.tar.bz2
rbot-gentoo-a3c12a104f9293ab3ce9b8cf440f2f0636fb46fa.zip
!*dep: Fix handling errors
-rw-r--r--gentoo-data.rb18
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