eliminate guesswork with Vagrantfile errors
If the Vagrantfile has some kind of error, display not only its path and the exception message, but also the originating line number and exception class. Also log the full backtrace when the error is in a provider block, just as it is done when it's outside a provider block.
This commit is contained in:
parent
e9b11b4ee4
commit
ce13051d61
|
@ -212,6 +212,8 @@ module Vagrant
|
||||||
# Report the generic exception
|
# Report the generic exception
|
||||||
raise Errors::VagrantfileLoadError,
|
raise Errors::VagrantfileLoadError,
|
||||||
path: path,
|
path: path,
|
||||||
|
line: e.backtrace[0].split(':')[1],
|
||||||
|
exception_class: e.class,
|
||||||
message: e.message
|
message: e.message
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,6 +37,8 @@ module VagrantPlugins
|
||||||
attr_reader :provisioners
|
attr_reader :provisioners
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
|
@logger = Log4r::Logger.new("vagrant::config::vm")
|
||||||
|
|
||||||
@base_mac = UNSET_VALUE
|
@base_mac = UNSET_VALUE
|
||||||
@boot_timeout = UNSET_VALUE
|
@boot_timeout = UNSET_VALUE
|
||||||
@box = UNSET_VALUE
|
@box = UNSET_VALUE
|
||||||
|
@ -446,8 +448,13 @@ module VagrantPlugins
|
||||||
config = config.merge(new_config)
|
config = config.merge(new_config)
|
||||||
end
|
end
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
|
@logger.error("Vagrantfile load error: #{e.message}")
|
||||||
|
@logger.error(e.backtrace.join("\n"))
|
||||||
|
|
||||||
raise Vagrant::Errors::VagrantfileLoadError,
|
raise Vagrant::Errors::VagrantfileLoadError,
|
||||||
path: "<provider config: #{name}>",
|
path: "<provider config: #{name}>",
|
||||||
|
line: e.backtrace[0].split(':')[1],
|
||||||
|
exception_class: e.class,
|
||||||
message: e.message
|
message: e.message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1200,7 +1200,8 @@ en:
|
||||||
a syntax error.
|
a syntax error.
|
||||||
|
|
||||||
Path: %{path}
|
Path: %{path}
|
||||||
Message: %{message}
|
Line number: %{line}
|
||||||
|
Message: %{exception_class}: %{message}
|
||||||
vagrantfile_syntax_error: |-
|
vagrantfile_syntax_error: |-
|
||||||
There is a syntax error in the following Vagrantfile. The syntax error
|
There is a syntax error in the following Vagrantfile. The syntax error
|
||||||
message is reproduced below for convenience:
|
message is reproduced below for convenience:
|
||||||
|
|
Loading…
Reference in New Issue