Expose the exception which triggers recovery methods through the "vagrant.error" environmental hash

This commit is contained in:
Mitchell Hashimoto 2010-09-13 23:43:37 -06:00
parent d5ad387f27
commit 7c42300002
2 changed files with 7 additions and 2 deletions

View File

@ -23,7 +23,9 @@ module Vagrant
raise Errors::VagrantInterrupt.new if env.interrupted? raise Errors::VagrantInterrupt.new if env.interrupted?
@stack.unshift(@actions.shift).first.call(env) @stack.unshift(@actions.shift).first.call(env)
raise Errors::VagrantInterrupt.new if env.interrupted? raise Errors::VagrantInterrupt.new if env.interrupted?
rescue rescue Exception => e
env["vagrant.error"] = e
# Something went horribly wrong. Start the rescue chain then # Something went horribly wrong. Start the rescue chain then
# reraise the exception to properly kick us out of limbo here. # reraise the exception to properly kick us out of limbo here.
begin_rescue(env) begin_rescue(env)

View File

@ -63,7 +63,10 @@ class ActionWardenTest < Test::Unit::TestCase
end end
@instance.actions << Foo.new @instance.actions << Foo.new
@instance.expects(:begin_rescue) @instance.expects(:begin_rescue).with() do |env|
assert env["vagrant.error"].is_a?(RuntimeError)
true
end
assert_raises(RuntimeError) { @instance.call(new_env) } assert_raises(RuntimeError) { @instance.call(new_env) }
end end