Be more defensive when trying to get the line number
Since this is the last line of defense before raising an error, we want to make sure we don't cause an error while trying to render the error.
This commit is contained in:
parent
ce13051d61
commit
6b2ef13785
|
@ -209,10 +209,15 @@ module Vagrant
|
|||
@logger.error("Vagrantfile load error: #{e.message}")
|
||||
@logger.error(e.backtrace.join("\n"))
|
||||
|
||||
line = "(unknown)"
|
||||
if e.backtrace && e.backtrace[0]
|
||||
line = e.backtrace[0].split(":")[1]
|
||||
end
|
||||
|
||||
# Report the generic exception
|
||||
raise Errors::VagrantfileLoadError,
|
||||
path: path,
|
||||
line: e.backtrace[0].split(':')[1],
|
||||
line: line,
|
||||
exception_class: e.class,
|
||||
message: e.message
|
||||
end
|
||||
|
|
|
@ -449,11 +449,18 @@ module VagrantPlugins
|
|||
end
|
||||
rescue Exception => e
|
||||
@logger.error("Vagrantfile load error: #{e.message}")
|
||||
@logger.error(e.inspect)
|
||||
@logger.error(e.message)
|
||||
@logger.error(e.backtrace.join("\n"))
|
||||
|
||||
line = "(unknown)"
|
||||
if e.backtrace && e.backtrace[0]
|
||||
line = e.backtrace[0].split(":")[1]
|
||||
end
|
||||
|
||||
raise Vagrant::Errors::VagrantfileLoadError,
|
||||
path: "<provider config: #{name}>",
|
||||
line: e.backtrace[0].split(':')[1],
|
||||
line: line,
|
||||
exception_class: e.class,
|
||||
message: e.message
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue