From f858468dbc31968e517119895225d5feecd8f747 Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Fri, 14 Nov 2008 07:39:25 +0000 Subject: Exception handling is important. --- gentoo-data.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3-65-gdbad