Skip to content

Fix `BacktraceFormatter` to handle `nil` backtraces.

gitlab-qa-bot requested to merge fix-backtrace-formatter-regression into master

Created by: myronmarston

Exception.new.backtrace is nil so we can't count on there always being a backtrace. Before now we relied on the format_backtrace caller handling this (passing ex.backtrace || []), but with #2074 now also including the exception.cause in failure output, the code there did not guard the format_backtrace call with || [] and is causing users to get a NoMethodError. It's easiest if format_backtrace just handles thenil` case so each caller does not have to remember to handle it.

Fixes #2117 (closed).

Merge request reports