diff --git a/lib/vagrant/action/builder.rb b/lib/vagrant/action/builder.rb index b006b15f5..36913952a 100644 --- a/lib/vagrant/action/builder.rb +++ b/lib/vagrant/action/builder.rb @@ -110,13 +110,9 @@ module Vagrant # @param [Vagrant::Action::Environment] env The action environment # @return [Object] A callable object def to_app(env) - # Prepend the error halt task so errneous environments are halted - # before the chain even begins. - middleware = stack.dup.push([Env::ErrorHalt, [], nil]) - - # Convert each middleware into a lambda which takes the next - # middleware. - Vagrant::Action::Warden.new(middleware, env) + # Wrap the middleware stack with the Warden to provide a consistent + # and predictable behavior upon exceptions. + Warden.new(stack.dup, env) end # Runs the builder stack with the given environment. diff --git a/lib/vagrant/action/env/error_halt.rb b/lib/vagrant/action/env/error_halt.rb deleted file mode 100644 index 570b693ff..000000000 --- a/lib/vagrant/action/env/error_halt.rb +++ /dev/null @@ -1,16 +0,0 @@ -module Vagrant - class Action - module Env - # A middleware which simply halts if the environment is erroneous. - class ErrorHalt - def initialize(app,env) - @app = app - end - - def call(env) - @app.call(env) if !env.error? - end - end - end - end -end diff --git a/test/vagrant/action/builder_test.rb b/test/vagrant/action/builder_test.rb index c8f4897a1..60965bb14 100644 --- a/test/vagrant/action/builder_test.rb +++ b/test/vagrant/action/builder_test.rb @@ -159,17 +159,6 @@ class ActionBuilderTest < Test::Unit::TestCase Vagrant::Action.actions.clear end - should "preprend error halt to the chain" do - result = mock("result") - env = {:a => :b} - middleware = mock("middleware") - middleware.stubs(:is_a?).with(Class).returns(true) - middleware.expects(:new).with(anything, env).returns(result) - @instance.use middleware - result = @instance.to_app(env).actions.first - assert result.kind_of?(Vagrant::Action::Env::ErrorHalt) - end - should "make non-classes lambdas" do env = Vagrant::Action::Environment.new(nil) env.expects(:foo).once diff --git a/test/vagrant/action/env/error_halt_test.rb b/test/vagrant/action/env/error_halt_test.rb deleted file mode 100644 index b0dbc0fa8..000000000 --- a/test/vagrant/action/env/error_halt_test.rb +++ /dev/null @@ -1,21 +0,0 @@ -require "test_helper" - -class ErrorHaltEnvActionTest < Test::Unit::TestCase - setup do - @klass = Vagrant::Action::Env::ErrorHalt - @app, @env = mock_action_data - @instance = @klass.new(@app, @env) - end - - should "continue the chain if no error" do - assert !@env.error? - @app.expects(:call).with(@env).once - @instance.call(@env) - end - - should "halt the chain if an error occured" do - @env.error!(:foo) - @app.expects(:call).never - @instance.call(@env) - end -end