From eed81d64f0f68fe509c4e436a5b6c3e4c7b68a0b Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 24 Jul 2010 09:18:10 -0700 Subject: [PATCH] No need to catch action exception on downloaders. Converted to using proper environment errors. --- lib/vagrant/action/box/download.rb | 6 ++---- lib/vagrant/downloaders/file.rb | 2 +- test/vagrant/downloaders/file_test.rb | 6 +++--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/vagrant/action/box/download.rb b/lib/vagrant/action/box/download.rb index 19b8751ca..e9d5c2d43 100644 --- a/lib/vagrant/action/box/download.rb +++ b/lib/vagrant/action/box/download.rb @@ -19,11 +19,9 @@ module Vagrant def call(env) @env = env - catch_action_exception(env) do - download if instantiate_downloader - end - + download if instantiate_downloader return if env.error? + @app.call(@env) cleanup diff --git a/lib/vagrant/downloaders/file.rb b/lib/vagrant/downloaders/file.rb index e0adf2ee9..38ba7bf34 100644 --- a/lib/vagrant/downloaders/file.rb +++ b/lib/vagrant/downloaders/file.rb @@ -9,7 +9,7 @@ module Vagrant def prepare(source_url) if !::File.file?(source_url) - raise Action::ActionException.new(:downloader_file_doesnt_exist, :source_url => source_url) + return env.error!(:downloader_file_doesnt_exist, :source_url => source_url) end end diff --git a/test/vagrant/downloaders/file_test.rb b/test/vagrant/downloaders/file_test.rb index 3512b9818..eb979034e 100644 --- a/test/vagrant/downloaders/file_test.rb +++ b/test/vagrant/downloaders/file_test.rb @@ -9,9 +9,9 @@ class FileDownloaderTest < Test::Unit::TestCase context "preparing" do should "raise an exception if the file does not exist" do File.expects(:file?).with(@uri).returns(false) - assert_raises(Vagrant::Action::ActionException) { - @downloader.prepare(@uri) - } + @downloader.prepare(@uri) + assert @downloader.env.error? + assert_equal :downloader_file_doesnt_exist, @downloader.env.error.first end end