Failure to load plugins raises confusing exception
phiggins opened this issue · 4 comments
Debride.load_plugins
currently swallows exceptions and returns nil, when the caller Debride.file_extensions
is expecting an array. This makes file_extensions
raise an exception because it is trying to do %w[rake rb] + nil
and fails.
I can think of a few ways to solve this but I wanted to get your opinion before I attempted any fixes:
- Don't swallow exceptions in
load_plugins
and just let it crash. - Continue swallowing exceptions in
load_plugins
but make the rescue block at the end return an empty array or@@plugins
. - Have
file_extensions
coerce the return value ofload_plugins
into an array by usingArray
or something.
In case you're curious what led to this: something was busted in my local setup. I run debride on $dayjob's big old rails app but I don't add debride to the Gemfile to avoid throwing more fuel on that fire. Debride worked if I put it in the Gemfile and ran bundle
, but not if I left it out of the Gemfile and installed it with gem install
. It turns out I was running into this exception and updating to the latest version of rubygems made it work again: rubygems/rubygems#1420
BTW I think I prefer solution 1 because it would have helped me debug the problem faster. WDYT?
You want to swallow exceptions so plugins can try to require dependencies and fail.
OK. I fixed the inner rescue to get RuntimeError
as well as LoadError
so now they'll report that they had a problem and move on cleanly. Top level rescue is probably not necessary now, but I made it return an empty array.
Cool, thank you!