Permalink
Browse files

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>
  • Loading branch information...
mackuba authored and josevalim committed Aug 20, 2010
1 parent 55c1f35 commit aec084955df4761dfc60920048209314ee466463
Showing with 8 additions and 4 deletions.
  1. +8 −4 activesupport/lib/active_support/deprecation/reporting.rb
@@ -46,10 +46,14 @@ def deprecation_caller_message(callstack)
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

0 comments on commit aec0849

Please sign in to comment.