]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/plugins.rb
[registry] refactoring into a abstract and factory
[user/henk/code/ruby/rbot.git] / lib / rbot / plugins.rb
index 55733ceed5417b481a285175321eaa11a3f44fe0..c499fd40ccef26c21ea2e24c4a966541b2c24dcf 100644 (file)
@@ -187,7 +187,7 @@ module Plugins
       @botmodule_triggers = Array.new
 
       @handler = MessageMapper.new(self)
-      @registry = Registry::Accessor.new(@bot, self.class.to_s.gsub(/^.*::/, ""))
+      @registry = @bot.registry_factory.create(@bot.path, self.class.to_s.gsub(/^.*::/, ''))
 
       @manager.add_botmodule(self)
       if self.respond_to?('set_language')
@@ -587,7 +587,7 @@ module Plugins
         }
         begin
           newerr = err.class.new(msg)
-        rescue ArgumentError => err_in_err
+        rescue ArgumentError => aerr_in_err
           # Somebody should hang the ActiveSupport developers by their balls
           # with barbed wire. Their MissingSourceFile extension to LoadError
           # _expects_ a second argument, breaking the usual Exception interface
@@ -600,7 +600,15 @@ module Plugins
           if err.class.respond_to? :from_message
             newerr = err.class.from_message(msg)
           else
-            raise err_in_err
+            raise aerr_in_err
+          end
+        rescue NoMethodError => nmerr_in_err
+          # Another braindead extension to StandardError, OAuth2::Error,
+          # doesn't get a string as message, but a response
+          if err.respond_to? :response
+            newerr = err.class.new(err.response)
+          else
+            raise nmerr_in_err
           end
         end
         newerr.set_backtrace(bt)
@@ -677,7 +685,13 @@ module Plugins
             end
           end
 
-          did_it = load_botmodule_file("#{dir}/#{file}", "plugin")
+          begin
+            did_it = load_botmodule_file("#{dir}/#{file}", "plugin")
+          rescue Exception => e
+            error e
+            did_it = e
+          end
+
           case did_it
           when Symbol
             processed[file.intern] = did_it
@@ -941,7 +955,6 @@ module Plugins
           rescue Exception => err
             raise if err.kind_of?(SystemExit)
             error report_error("#{p.botmodule_class} #{p.name} #{method}() failed:", err)
-            raise if err.kind_of?(BDB::Fatal)
           end
         }
       else
@@ -957,7 +970,6 @@ module Plugins
             rescue Exception => err
               raise if err.kind_of?(SystemExit)
               error report_error("#{p.botmodule_class} #{p.name} #{method}() failed:", err)
-              raise if err.kind_of?(BDB::Fatal)
             end
           end
         }
@@ -987,7 +999,6 @@ module Plugins
             rescue Exception => err
               raise if err.kind_of?(SystemExit)
               error report_error("#{p.botmodule_class} #{p.name} privmsg() failed:", err)
-              raise if err.kind_of?(BDB::Fatal)
             end
             debug "Successfully delegated #{m.inspect}"
             return true