From 06185978eaf9d0eaef5089afb97ae8ca521a41b1 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Tue, 11 Sep 2007 11:22:40 +0000 Subject: translator plugin: catch all exceptions when trying to initialize translators The most significant exception that wasn't catched was LoadError, so that a failing require 'mechanize' would cause the whole plugin from failing to load, instead of just disabling the translators depending on WWW::Mechanize --- data/rbot/plugins/translator.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'data/rbot') diff --git a/data/rbot/plugins/translator.rb b/data/rbot/plugins/translator.rb index 65348d0f..c2b74eeb 100644 --- a/data/rbot/plugins/translator.rb +++ b/data/rbot/plugins/translator.rb @@ -209,7 +209,7 @@ class BabelfishTranslator < Translator def initialize(cache) require 'mechanize' - + @form = WWW::Mechanize.new.get('http://babelfish.altavista.com/babelfish/'). forms.name('frmTrText').first @lang_list = @form.fields.name('lp') @@ -272,7 +272,7 @@ class TranslatorPlugin < Plugin begin @translators[name] = c.new(@registry.sub_registry(name)) map "#{name} :from :to *phrase", :action => :cmd_translate - rescue + rescue Exception warning _("Translator %{name} cannot be used: %{reason}") % {:name => name, :reason => $!} end -- cgit v1.2.3