Always log the exception raised when error loading a plugin

This commit is contained in:
Mitchell Hashimoto 2013-02-22 15:11:01 -08:00
parent 1b6538354d
commit 29600d3d06
1 changed files with 8 additions and 8 deletions

View File

@ -170,6 +170,14 @@ module Vagrant
begin
require name
rescue Exception => e
# Since this is a rare case, we create a one-time logger here
# in order to output the error
logger = Log4r::Logger.new("vagrant::root")
logger.error("Failed to load plugin: #{name}")
logger.error(" -- Error: #{e.inspect}")
logger.error(" -- Backtrace:")
logger.error(e.backtrace.join("\n"))
# If it is a LoadError we first try to see if it failed loading
# the top-level entrypoint. If so, then we report a different error.
if e.is_a?(LoadError)
@ -181,14 +189,6 @@ module Vagrant
end
end
# Since this is a rare case, we create a one-time logger here
# in order to output the error
logger = Log4r::Logger.new("vagrant::root")
logger.error("Failed to load plugin: #{name}")
logger.error(" -- Error: #{e.inspect}")
logger.error(" -- Backtrace:")
logger.error(e.backtrace.join("\n"))
# And raise an error itself
raise Errors::PluginLoadFailed, :plugin => name
end