diff options
author | 2008-11-14 07:39:25 +0000 | |
---|---|---|
committer | 2008-11-14 07:39:25 +0000 | |
commit | f858468dbc31968e517119895225d5feecd8f747 (patch) | |
tree | ddc683126f6a53be2ac64586542b9c64270899c7 | |
parent | Escape regex metachars. (diff) | |
download | rbot-gentoo-f858468dbc31968e517119895225d5feecd8f747.tar.gz rbot-gentoo-f858468dbc31968e517119895225d5feecd8f747.tar.bz2 rbot-gentoo-f858468dbc31968e517119895225d5feecd8f747.zip |
Exception handling is important.
-rw-r--r-- | gentoo-data.rb | 16 |
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 |