diff options
author | Jakub Suder <jakub.suder@gmail.com> | 2010-08-20 20:05:38 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-08-25 07:23:50 -0300 |
commit | 4f945e97e55b861ab014d71efa983ab183441031 (patch) | |
tree | e428fb2a802370341dbceb57951abf36b6eddb6d | |
parent | 0b9357d401677f289994369e48c2065880978a53 (diff) | |
download | rails-4f945e97e55b861ab014d71efa983ab183441031.tar.gz rails-4f945e97e55b861ab014d71efa983ab183441031.tar.bz2 rails-4f945e97e55b861ab014d71efa983ab183441031.zip |
better callstack reporting in deprecation messages
now the reported line is the first line in the stack
that's outside Rails, which is the one that actually
caused the problem in the first place
[#5231 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
-rw-r--r-- | activesupport/lib/active_support/deprecation/reporting.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/deprecation/reporting.rb b/activesupport/lib/active_support/deprecation/reporting.rb index 49d58cd3a1..6a7b11c7e0 100644 --- a/activesupport/lib/active_support/deprecation/reporting.rb +++ b/activesupport/lib/active_support/deprecation/reporting.rb @@ -46,10 +46,14 @@ module ActiveSupport end def extract_callstack(callstack) - if md = callstack.first.match(/^(.+?):(\d+)(?::in `(.*?)')?/) - md.captures - else - callstack.first + rails_gem_root = File.expand_path("../../../../..", __FILE__) + "/" + offending_line = callstack.find { |line| !line.start_with?(rails_gem_root) } || callstack.first + if offending_line + if md = offending_line.match(/^(.+?):(\d+)(?::in `(.*?)')?/) + md.captures + else + offending_line + end end end end |