From a3c12a104f9293ab3ce9b8cf440f2f0636fb46fa Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Fri, 12 Aug 2016 18:34:42 +0200 Subject: !*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 -- cgit v1.2.3-65-gdbad