Fixes #11022: Ensure correct line is used for windows exceptions

Prior to this commit, if there was a config error inside a provider
block, Vagrant wouldn't grab the right backtrace token on windows since
the api is different for ruby on Windows compared to all other
platforms. This commit ensures that the proper line number is chosen so
the error message is correct.
This commit is contained in:
Brian Cain 2019-09-06 13:52:52 -07:00
parent ccf99d8c0c
commit 09a37e0767
No known key found for this signature in database
GPG Key ID: 9FC4639B2E4510A0
1 changed files with 7 additions and 1 deletions

View File

@ -509,8 +509,14 @@ module VagrantPlugins
line = "(unknown)"
if e.backtrace && e.backtrace[0]
if Vagrant::Util::Platform.windows?
# path is split into two tokens on windows for some reason...
# where 0th is drive letter, 1st is path, so line number is token 2
line = e.backtrace[0].split(":")[2]
else
line = e.backtrace[0].split(":")[1]
end
end
raise Vagrant::Errors::VagrantfileLoadError,
path: "<provider config: #{name}>",