Raise interrupt error earlier so the rescue chain actually gets called
This commit is contained in:
parent
f00955dfa1
commit
71101c9d3d
|
@ -21,6 +21,7 @@ module Vagrant
|
|||
# Call the next middleware in the sequence, appending to the stack
|
||||
# of "recoverable" middlewares in case something goes wrong!
|
||||
@stack.unshift(@actions.shift).first.call(env)
|
||||
raise Errors::VagrantInterrupt.new if env.interrupted?
|
||||
rescue
|
||||
# Something went horribly wrong. Start the rescue chain then
|
||||
# reraise the exception to properly kick us out of limbo here.
|
||||
|
@ -33,8 +34,6 @@ module Vagrant
|
|||
@stack.each do |act|
|
||||
act.recover(env) if act.respond_to?(:recover)
|
||||
end
|
||||
|
||||
raise Errors::VagrantInterrupt.new if env.interrupted?
|
||||
end
|
||||
|
||||
def finalize_action(action, env)
|
||||
|
|
|
@ -66,6 +66,16 @@ class ActionWardenTest < Test::Unit::TestCase
|
|||
@instance.expects(:begin_rescue)
|
||||
assert_raises(RuntimeError) { @instance.call(new_env) }
|
||||
end
|
||||
|
||||
should "raise interrupt if the environment is interupted" do
|
||||
env = new_env
|
||||
env.expects(:interrupted?).returns(true)
|
||||
@instance.actions << lambda { |env| }
|
||||
|
||||
assert_raises(Vagrant::Errors::VagrantInterrupt) {
|
||||
@instance.call(env)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
context "recover" do
|
||||
|
@ -78,20 +88,6 @@ class ActionWardenTest < Test::Unit::TestCase
|
|||
|
||||
@instance.begin_rescue(new_env)
|
||||
end
|
||||
|
||||
should "call exit if the environment is interupted" do
|
||||
env = new_env
|
||||
env.expects(:interrupted?).returns(true)
|
||||
assert_raises(Vagrant::Errors::VagrantInterrupt) {
|
||||
@instance.begin_rescue(env)
|
||||
}
|
||||
end
|
||||
|
||||
context "with many middleware" do
|
||||
should "not call middleware after" do
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def new_env
|
||||
|
|
Loading…
Reference in New Issue