From 7c42300002718375614b4577ba2b20f2fbc9c76d Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 13 Sep 2010 23:43:37 -0600 Subject: [PATCH] Expose the exception which triggers recovery methods through the "vagrant.error" environmental hash --- lib/vagrant/action/warden.rb | 4 +++- test/vagrant/action/warden_test.rb | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/vagrant/action/warden.rb b/lib/vagrant/action/warden.rb index 77190100e..3d509d5c0 100644 --- a/lib/vagrant/action/warden.rb +++ b/lib/vagrant/action/warden.rb @@ -23,7 +23,9 @@ module Vagrant raise Errors::VagrantInterrupt.new if env.interrupted? @stack.unshift(@actions.shift).first.call(env) raise Errors::VagrantInterrupt.new if env.interrupted? - rescue + rescue Exception => e + env["vagrant.error"] = e + # Something went horribly wrong. Start the rescue chain then # reraise the exception to properly kick us out of limbo here. begin_rescue(env) diff --git a/test/vagrant/action/warden_test.rb b/test/vagrant/action/warden_test.rb index 6e8015057..72377afa7 100644 --- a/test/vagrant/action/warden_test.rb +++ b/test/vagrant/action/warden_test.rb @@ -63,7 +63,10 @@ class ActionWardenTest < Test::Unit::TestCase end @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) } end