ActionException on Vagrant::Action
This commit is contained in:
parent
ff7e9dc2ae
commit
13a46ac1bd
|
@ -0,0 +1,16 @@
|
||||||
|
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
|
|
@ -219,7 +219,7 @@ module Vagrant
|
||||||
}
|
}
|
||||||
}.merge(options || {})
|
}.merge(options || {})
|
||||||
|
|
||||||
raise Actions::ActionException.new(options[:error_key], options[:error_data])
|
raise Action::ActionException.new(options[:error_key], options[:error_data])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -119,7 +119,7 @@ module Vagrant
|
||||||
break unless result
|
break unless result
|
||||||
|
|
||||||
attempts += 1
|
attempts += 1
|
||||||
raise Actions::ActionException.new(:vm_mount_fail) if attempts >= 10
|
raise Action::ActionException.new(:vm_mount_fail) if attempts >= 10
|
||||||
sleep sleeptime
|
sleep sleeptime
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,7 +19,7 @@ class SshSessionTest < Test::Unit::TestCase
|
||||||
|
|
||||||
context "checking exit status" do
|
context "checking exit status" do
|
||||||
should "raise an ActionException if its non-zero" do
|
should "raise an ActionException if its non-zero" do
|
||||||
assert_raises(Vagrant::Actions::ActionException) {
|
assert_raises(Vagrant::Action::ActionException) {
|
||||||
@instance.check_exit_status(1, "foo")
|
@instance.check_exit_status(1, "foo")
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -30,7 +30,7 @@ class SshSessionTest < Test::Unit::TestCase
|
||||||
:error_data => {}
|
:error_data => {}
|
||||||
}
|
}
|
||||||
result = Exception.new
|
result = Exception.new
|
||||||
Vagrant::Actions::ActionException.expects(:new).with(options[:error_key], options[:error_data]).once.returns(result)
|
Vagrant::Action::ActionException.expects(:new).with(options[:error_key], options[:error_data]).once.returns(result)
|
||||||
|
|
||||||
assert_raises(Exception) {
|
assert_raises(Exception) {
|
||||||
@instance.check_exit_status(1, "foo", options)
|
@instance.check_exit_status(1, "foo", options)
|
||||||
|
|
|
@ -149,7 +149,7 @@ class LinuxSystemTest < Test::Unit::TestCase
|
||||||
should "raise an ActionException if the command fails constantly" do
|
should "raise an ActionException if the command fails constantly" do
|
||||||
@ssh.expects(:exec!).times(@limit).returns(!@success_return)
|
@ssh.expects(:exec!).times(@limit).returns(!@success_return)
|
||||||
|
|
||||||
assert_raises(Vagrant::Actions::ActionException) {
|
assert_raises(Vagrant::Action::ActionException) {
|
||||||
mount_folder
|
mount_folder
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue