diff --git a/lib/vagrant/config/loader.rb b/lib/vagrant/config/loader.rb index 35b0d0828..2ebd339a1 100644 --- a/lib/vagrant/config/loader.rb +++ b/lib/vagrant/config/loader.rb @@ -212,6 +212,8 @@ module Vagrant # Report the generic exception raise Errors::VagrantfileLoadError, path: path, + line: e.backtrace[0].split(':')[1], + exception_class: e.class, message: e.message end end diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index 155a0d62f..ed4e750fb 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -37,6 +37,8 @@ module VagrantPlugins attr_reader :provisioners def initialize + @logger = Log4r::Logger.new("vagrant::config::vm") + @base_mac = UNSET_VALUE @boot_timeout = UNSET_VALUE @box = UNSET_VALUE @@ -446,8 +448,13 @@ module VagrantPlugins config = config.merge(new_config) end rescue Exception => e + @logger.error("Vagrantfile load error: #{e.message}") + @logger.error(e.backtrace.join("\n")) + raise Vagrant::Errors::VagrantfileLoadError, path: "", + line: e.backtrace[0].split(':')[1], + exception_class: e.class, message: e.message end diff --git a/templates/locales/en.yml b/templates/locales/en.yml index f96fb9312..acff0a687 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -1200,7 +1200,8 @@ en: a syntax error. Path: %{path} - Message: %{message} + Line number: %{line} + Message: %{exception_class}: %{message} vagrantfile_syntax_error: |- There is a syntax error in the following Vagrantfile. The syntax error message is reproduced below for convenience: