commit: a3c12a104f9293ab3ce9b8cf440f2f0636fb46fa
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 12 16:34:42 2016 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Aug 13 18:23:45 2016 +0000
URL: https://gitweb.gentoo.org/proj/rbot-gentoo.git/commit/?id=a3c12a10
!*dep: Fix handling errors
gentoo-data.rb | 18 ++++++++++--------
1 file 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