Skip to content

Commit

Permalink
Remove generated code from app traces; improve accuracy of framework …
Browse files Browse the repository at this point in the history
…traces

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2676 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
seckar committed Oct 18, 2005
1 parent 851dd08 commit 60b6fac
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions activesupport/CHANGELOG
@@ -1,3 +1,8 @@
* Classify generated routing code as framework code to avoid appearing in application traces. [Nicholas Seckar]

* Show all framework frames in the framework trace. [Nicholas Seckar]


*1.2.0* (October 16th, 2005)

* Update Exception extension to show the first few framework frames in an application trace. [Nicholas Seckar]
Expand Down
7 changes: 6 additions & 1 deletion activesupport/lib/active_support/core_ext/exception.rb
Expand Up @@ -3,6 +3,7 @@ class Exception
alias :clean_message :message

TraceSubstitutions = []
FrameworkRegexp = /generated_code|vendor|dispatch|ruby|script\/\w+/

def clean_backtrace
backtrace.collect do |line|
Expand All @@ -16,9 +17,13 @@ def application_backtrace
before_application_frame = true

clean_backtrace.reject do |line|
non_app_frame = !! (line =~ /vendor|dispatch|ruby|script\/\w+/)
non_app_frame = !! (line =~ FrameworkRegexp)
before_application_frame = false unless non_app_frame
non_app_frame && ! before_application_frame
end
end

def framework_backtrace
clean_backtrace.select {|line| line =~ FrameworkRegexp}
end
end
8 changes: 8 additions & 0 deletions activesupport/test/core_ext/exception_test.rb
Expand Up @@ -34,5 +34,13 @@ def test_app_backtrace_with_before
assert_kind_of Exception, e
assert_equal ['vendor/file.rb some stuff', 'bhal.rb', 'almost all'], e.application_backtrace
end

def test_framework_backtrace_with_before
Exception::TraceSubstitutions << [/\s*hidden.*/, '']
e = get_exception RuntimeError, 'RAWR', ['vendor/file.rb some stuff', 'bhal.rb', ' vendor/file.rb some stuff', 'almost all']
assert_kind_of Exception, e
assert_equal ['vendor/file.rb some stuff', ' vendor/file.rb some stuff'], e.framework_backtrace
end


end

0 comments on commit 60b6fac

Please sign in to comment.