Simplify line and path checks for exception handling in config loading

This commit is contained in:
Brian Cain 2019-09-10 13:27:23 -07:00
parent 09a37e0767
commit a22acba467
No known key found for this signature in database
GPG Key ID: 9FC4639B2E4510A0
2 changed files with 3 additions and 14 deletions

View File

@ -131,13 +131,8 @@ module Vagrant
path = "(unknown)"
if e.backtrace && e.backtrace[0]
backtrace_tokens = e.backtrace[0].split(":")
if Vagrant::Util::Platform.windows?
# path is split into two tokens on windows for some reason...
# where 0th is drive letter, 1st is path
path = backtrace_tokens[0] + ":" + backtrace_tokens[1]
else
path = backtrace_tokens[0]
end
path = e.backtrace.first.slice(0, e.backtrace.first.rindex(':')).rpartition(':').first
backtrace_tokens.each do |part|
if part =~ /\d+/
line = part.to_i

View File

@ -509,13 +509,7 @@ 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
line = e.backtrace.first.slice(0, e.backtrace.first.rindex(':')).rpartition(':').last
end
raise Vagrant::Errors::VagrantfileLoadError,