-
-
Notifications
You must be signed in to change notification settings - Fork 755
Option for "Caused by" backtraces to print more than just the first line #3027
Comments
👋 I'd happily look at PR to improve this, the original behaviour is largely because when it was introduced
No (with the caveat of I'm on the fence as to whether
I like the idea of this being a seperate config, what would the three options do? I'm happy for this to be a single "
I'd support making the backtrace option take options on the cli e.g. |
This was resolved by #3046, and was released in v3.13.0 |
Thank you for the reminder 😹 |
Subject of the issue
When debugging a failed spec where the proximate exception is caused by another exception, I've found that it is very rarely the case that the single line of the causing exception backtrace is sufficient to determine the fault. RSpec prints the backtrace of the proximate exception with all (relevant) lines, but the causing exception backtrace is hard-coded to only present the first line of the causing exception's backtrace.
It would be really handy (for me, at any rate) if there were an option to turn on full(er) backtraces for causing exceptions. Personally, I'd be fine if it were tied to the
--backtrace
CLI option (aka theRSpec.configure
full_backtrace
option), because I'm willing to wade through long backtraces if necessary, but I can imagine it'd be a better UX if new config options were introduced to control the degree to which the causing exception backtrace is truncated.I'd also be quite happy if the default were changed, although I assume that the current behaviour (which dates back to the initial introduction of the feature) was done for a good reason. Interestingly, the example provided in the commit message for the original change shows a full backtrace for the causing exception, even though the code behaves differently. 🤔
I'm more than happy to whip up a PR if someone would like to give guidance on the various undecided questions raised:
full_backtrace
? If the former, should there be one option (sayconfig.cause_backtrace = [:oneline|:regular|:full]
) or multiple options (config.cause_backtrace_oneline = true/false
,config.full_cause_backtrace = true/false
), or something else?RSpec.configure
sufficient for something that is, by the look of it, a very niche feature?Your environment
Steps to reproduce
This script produces a nested exception with a multi-level causing-exception backtrace:
Expected behavior
This is the output of a lightly-mangled
rspec-core
that at least prints out a slightly fuller causing backtrace:The formatting could be (a lot) better, but it gives me enough information to be able to determine how the exception-raising function
baz
was called, which is often relevant information when I'm debugging.Actual behavior
This is the output of the repro script when run against a stock
rspec-core-3.12.1
:If the exception raised in
baz
were somehow dependent on how it was called (which, let's face it, is pretty likely), the lack of backtrace makes it very hard to figure out what's going on.The text was updated successfully, but these errors were encountered: