From 4f945e97e55b861ab014d71efa983ab183441031 Mon Sep 17 00:00:00 2001 From: Jakub Suder Date: Fri, 20 Aug 2010 20:05:38 +0200 Subject: better callstack reporting in deprecation messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- activesupport/lib/active_support/deprecation/reporting.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'activesupport') 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 -- cgit v1.2.3