Raise error if incomplete trigger block is defined

This commit is contained in:
Brian Cain 2018-04-04 11:31:59 -07:00
parent 6bf01965de
commit 0054c5aae6
No known key found for this signature in database
GPG Key ID: 43D51080D357A001
3 changed files with 13 additions and 0 deletions

View File

@ -780,6 +780,10 @@ module Vagrant
error_key(:triggers_guest_not_running)
end
class TriggersNoBlockGiven < VagrantError
error_key(:triggers_no_block_given)
end
class TriggersNoStageGiven < VagrantError
error_key(:triggers_no_stage_given)
end

View File

@ -49,6 +49,9 @@ module VagrantPlugins
# so the last element should be the "config block"
# and the rest are commands for the trigger
blk = command.pop
elsif !block_given?
raise Vagrant::Errors::TriggersNoBlockGiven,
command: command
end
command.each do |cmd|
@ -71,6 +74,9 @@ module VagrantPlugins
# so the last element should be the "config block"
# and the rest are commands for the trigger
blk = command.pop
elsif !block_given?
raise Vagrant::Errors::TriggersNoBlockGiven,
command: command
end
command.each do |cmd|

View File

@ -1414,6 +1414,9 @@ en:
Trigger run failed
triggers_guest_not_running: |-
Could not run remote script on %{machine_name} because its state is %{state}
triggers_no_block_given: |-
There was an error parsing the Vagrantfile:
No config was given for the trigger(s) %{command}.
triggers_no_stage_given: |-
The incorrect stage was given to the trigger plugin:
Guest: %{guest_name}