diff --git a/lib/vagrant.rb b/lib/vagrant.rb index 315be5507..210b69871 100644 --- a/lib/vagrant.rb +++ b/lib/vagrant.rb @@ -32,7 +32,7 @@ I18n.load_path << File.expand_path("templates/locales/en.yml", Vagrant.source_ro libdir = File.expand_path("lib/vagrant", Vagrant.source_root) Vagrant::GlobLoader.glob_require(libdir, %w{util util/stacked_proc_runner downloaders/base config provisioners/base provisioners/chef systems/base - action/exception_catcher hosts/base}) + hosts/base}) # Initialize the built-in actions Vagrant::Action.builtin! diff --git a/lib/vagrant/action/action_exception.rb b/lib/vagrant/action/action_exception.rb deleted file mode 100644 index 3d5299215..000000000 --- a/lib/vagrant/action/action_exception.rb +++ /dev/null @@ -1,16 +0,0 @@ -module Vagrant - class Action - class ActionException < Exception - attr_reader :key - attr_reader :data - - def initialize(key, data = {}) - @key = key - @data = data - - message = Vagrant::Util::Translator.t(key, data) - super(message) - end - end - end -end diff --git a/lib/vagrant/action/exception_catcher.rb b/lib/vagrant/action/exception_catcher.rb deleted file mode 100644 index 35fe78547..000000000 --- a/lib/vagrant/action/exception_catcher.rb +++ /dev/null @@ -1,14 +0,0 @@ -module Vagrant - class Action - # A helper to catch any ActionExceptions raised and to - # apply the error to the environment. - module ExceptionCatcher - def catch_action_exception(env) - yield env - rescue ActionException => e - env.error!(e.key, e.data) - false - end - end - end -end diff --git a/lib/vagrant/action/vm/halt.rb b/lib/vagrant/action/vm/halt.rb index a2f0bd801..823722e87 100644 --- a/lib/vagrant/action/vm/halt.rb +++ b/lib/vagrant/action/vm/halt.rb @@ -2,8 +2,6 @@ module Vagrant class Action module VM class Halt - include ExceptionCatcher - def initialize(app, env, options=nil) @app = app env.merge!(options || {}) @@ -11,10 +9,7 @@ module Vagrant def call(env) if env["vm"].vm.running? - if !env["force"] - catch_action_exception(env) { env["vm"].system.halt } - return if env.error? - end + env["vm"].system.halt if !env["force"] if env["vm"].vm.state(true) != :powered_off env.ui.info "vagrant.actions.vm.halt.force" diff --git a/lib/vagrant/action/vm/network.rb b/lib/vagrant/action/vm/network.rb index 07e395eaa..c9ca0969e 100644 --- a/lib/vagrant/action/vm/network.rb +++ b/lib/vagrant/action/vm/network.rb @@ -4,8 +4,6 @@ module Vagrant # Networking middleware for Vagrant. This enables host only # networking on VMs if configured as such. class Network - include ExceptionCatcher - def initialize(app, env) @app = app @env = env @@ -22,12 +20,10 @@ module Vagrant @app.call(env) if enable_network? - catch_action_exception(env) do - @env.ui.info "vagrant.actions.vm.network.enabling" - @env["vm"].system.prepare_host_only_network - @env.env.config.vm.network_options.compact.each do |network_options| - @env["vm"].system.enable_host_only_network(network_options) - end + @env.ui.info "vagrant.actions.vm.network.enabling" + @env["vm"].system.prepare_host_only_network + @env.env.config.vm.network_options.compact.each do |network_options| + @env["vm"].system.enable_host_only_network(network_options) end end end diff --git a/lib/vagrant/action/vm/nfs.rb b/lib/vagrant/action/vm/nfs.rb index 067f3bfc0..1cf3bc49c 100644 --- a/lib/vagrant/action/vm/nfs.rb +++ b/lib/vagrant/action/vm/nfs.rb @@ -16,7 +16,6 @@ module Vagrant # folder. # class NFS - include ExceptionCatcher include NFSHelpers def initialize(app,env) @@ -107,18 +106,14 @@ module Vagrant def export_folders @env.ui.info "vagrant.actions.vm.nfs.exporting" - catch_action_exception(@env) do - @env["host"].nfs_export(guest_ip, folders) - end + @env["host"].nfs_export(guest_ip, folders) end # Uses the system class to mount the NFS folders. def mount_folders @env.ui.info "vagrant.actions.vm.nfs.mounting" - catch_action_exception(@env) do - @env["vm"].system.mount_nfs(host_ip, folders) - end + @env["vm"].system.mount_nfs(host_ip, folders) end # Returns the IP address of the first host only network adapter diff --git a/lib/vagrant/action/vm/share_folders.rb b/lib/vagrant/action/vm/share_folders.rb index 68dcbe9e5..cea5328f9 100644 --- a/lib/vagrant/action/vm/share_folders.rb +++ b/lib/vagrant/action/vm/share_folders.rb @@ -2,8 +2,6 @@ module Vagrant class Action module VM class ShareFolders - include ExceptionCatcher - def initialize(app, env) @app = app @env = env @@ -16,9 +14,7 @@ module Vagrant @app.call(env) - catch_action_exception(env) do - mount_shared_folders - end + mount_shared_folders end # This method returns an actual list of VirtualBox shared diff --git a/test/vagrant/action/exception_catcher_test.rb b/test/vagrant/action/exception_catcher_test.rb deleted file mode 100644 index 6304b1e70..000000000 --- a/test/vagrant/action/exception_catcher_test.rb +++ /dev/null @@ -1,30 +0,0 @@ -require "test_helper" - -class ExceptionCatcherTest < Test::Unit::TestCase - setup do - @klass = Class.new - @klass.send(:include, Vagrant::Action::ExceptionCatcher) - @env = Vagrant::Action::Environment.new(mock_environment) - - @instance = @klass.new - end - - should "run block and return result if no exception" do - result = @instance.catch_action_exception(@env) do - true - end - - assert result - assert !@env.error? - end - - should "run block and return false with error environment on exception" do - result = @instance.catch_action_exception(@env) do - raise Vagrant::Action::ActionException.new(:foo, :foo => :bar) - end - - assert !result - assert @env.error? - assert_equal :foo, @env.error.first - end -end diff --git a/test/vagrant/action/vm/nfs_test.rb b/test/vagrant/action/vm/nfs_test.rb index cb5749e6b..e27e0db5b 100644 --- a/test/vagrant/action/vm/nfs_test.rb +++ b/test/vagrant/action/vm/nfs_test.rb @@ -144,13 +144,6 @@ class NFSVMActionTest < Test::Unit::TestCase @env["host"].expects(:nfs_export).with(@instance.guest_ip, @instance.folders) @instance.export_folders end - - should "error the environment if exception is raised" do - @env["host"].expects(:nfs_export).raises(Vagrant::Action::ActionException.new(:foo)) - @instance.export_folders - assert @env.error? - assert_equal :foo, @env.error.first - end end context "mounting folders" do