lib/console/event/failure.rb in console-1.10.2 vs lib/console/event/failure.rb in console-1.11.0

- old
+ new

@@ -45,10 +45,12 @@ def self.register(terminal) terminal[:exception_title] ||= terminal.style(:red, nil, :bold) terminal[:exception_detail] ||= terminal.style(:yellow) terminal[:exception_backtrace] ||= terminal.style(:red) + terminal[:exception_backtrace_other] ||= terminal.style(:red, nil, :faint) + terminal[:exception_message] ||= terminal.style(:default) end def to_h {exception: @exception, root: @root} end @@ -64,18 +66,21 @@ lines.each do |line| output.puts " #{terminal[:exception_detail]}#{line}#{terminal.reset}" end - root_expr = /^#{@root}\// if @root - + root_pattern = /^#{@root}\// if @root + exception.backtrace&.each_with_index do |line, index| path, offset, message = line.split(":") + style = :exception_backtrace # Make the path a bit more readable - path.sub!(root_expr, "./") if root_expr - - output.puts " #{index == 0 ? "→" : " "} #{terminal[:exception_backtrace]}#{path}:#{offset}#{terminal.reset} #{message}" + if root_pattern and path.sub!(root_pattern, "").nil? + style = :exception_backtrace_other + end + + output.puts " #{index == 0 ? "→" : " "} #{terminal[style]}#{path}:#{offset}#{terminal[:exception_message]} #{message}#{terminal.reset}" end if exception.cause format_exception(exception.cause, "Caused by ", output, terminal, verbose) end