aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2008-11-14 07:39:25 +0000
committerRobin H. Johnson <robbat2@gentoo.org>2008-11-14 07:39:25 +0000
commitf858468dbc31968e517119895225d5feecd8f747 (patch)
treeddc683126f6a53be2ac64586542b9c64270899c7
parentEscape regex metachars. (diff)
downloadrbot-gentoo-f858468dbc31968e517119895225d5feecd8f747.tar.gz
rbot-gentoo-f858468dbc31968e517119895225d5feecd8f747.tar.bz2
rbot-gentoo-f858468dbc31968e517119895225d5feecd8f747.zip
Exception handling is important.
-rw-r--r--gentoo-data.rb16
1 files changed, 15 insertions, 1 deletions
diff --git a/gentoo-data.rb b/gentoo-data.rb
index 31c5b6b..992f396 100644
--- a/gentoo-data.rb
+++ b/gentoo-data.rb
@@ -268,7 +268,21 @@ class GentooPlugin < Plugin
cp = params[:pkg]
cp = validate_package(m, cp)
return if cp.nil?
- packages = @bot.httputil.get(url+cp).split("\n")
+
+ # Watch out for network problems
+ begin
+ packages = @bot.httputil.get(url+cp)
+ rescue ::Exception => e
+ m.reply 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