From: "Dan0042 (Daniel DeLorme)" Date: 2022-11-16T18:32:58+00:00 Subject: [ruby-core:110784] [Ruby master Feature#19117] Include the method owner in backtraces, not just the method name Issue #19117 has been updated by Dan0042 (Daniel DeLorme). > Not all code follow a convention where classes map to files 1 to 1. And that's why I wrote "usually/often", not "always". > That's not the case for methods defined in C (either core or C extensions) as mentioned above, so it's a significant help to read and understand the backtrace to have the owner there. Ok thank you, I missed that above. But I want to point out that since **usually** ruby code is written with the convention that classes map to files 1 to 1, and since the owner is right there in the filepath for the methods that are **defined in ruby**, for the majority of the stack trace you're going to see a lot of redundancy. ex: ``` /home/me/test/superspeed/server/events/socket/base.rb:7:in `Superspeed::Server::Events::Socket::Base#test': todo (RuntimeError) from /home/me/test/superspeed/server/events/socket/comm.rb:9:in `Superspeed::Server::Events::Socket::Comm#test1' from /home/me/test/superspeed/server/events/socket/comm.rb:18:in `
' ``` ---------------------------------------- Feature #19117: Include the method owner in backtraces, not just the method name https://bugs.ruby-lang.org/issues/19117#change-100130 * Author: byroot (Jean Boussier) * Status: Open * Priority: Normal ---------------------------------------- ``` module Foo class Bar def inspect 1 + '1' end end end p Foo::Bar.new ``` This code produce the following backtrace: ``` /tmp/foo.rb:4:in `+': String can't be coerced into Integer (TypeError) from /tmp/foo.rb:4:in `inspect' from /tmp/foo.rb:9:in `p' from /tmp/foo.rb:9:in `
' ``` This works, but on large codebases and large backtraces the method name isn't always all that revealing, most of the time you need to open many of the locations listed in the backtrace to really understand what is going on. I propose that we also include the owner name: ``` /tmp/foo.rb:4:in `Integer#+': String can't be coerced into Integer (TypeError) from /tmp/foo.rb:4:in `Foo::Bar#inspect' from /tmp/foo.rb:9:in `Kernel#p' from /tmp/foo.rb:9:in `
' ``` I believe that in many case it would allow to much better understand the backtrace without having to jump back and forth between it and the source code. This is inspired by @ivoanjo 's `backtracie` gem: https://github.com/ivoanjo/backtracie -- https://bugs.ruby-lang.org/ Unsubscribe: