diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2013-11-15 21:56:34 +0100 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2013-11-15 21:56:38 +0100 |
commit | 3a6abd145f03aee8bcf1e3aab38f94e80860b18d (patch) | |
tree | 6c5621312e14d41b336a4f7c1b669911d5cbf7d0 /lib/rbot/plugins.rb | |
parent | a518b9d475ca8223c89cb036ee3841bab35e916b (diff) |
plugins: improve error handling on load
Support OAuth2::Error braindead extension to StandardError and
wrap loading in an outer rescue to catch problems with the error
handling.
Diffstat (limited to 'lib/rbot/plugins.rb')
-rw-r--r-- | lib/rbot/plugins.rb | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/rbot/plugins.rb b/lib/rbot/plugins.rb index 9a41610f..493f177f 100644 --- a/lib/rbot/plugins.rb +++ b/lib/rbot/plugins.rb @@ -588,7 +588,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 @@ -601,7 +601,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) @@ -678,7 +686,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 |