aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activesupport/CHANGELOG4
-rw-r--r--activesupport/lib/active_support/core_ext/exception.rb8
-rw-r--r--activesupport/test/core_ext/exception_test.rb14
3 files changed, 24 insertions, 2 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index 40ea411ada..43ea126aaf 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -1,6 +1,8 @@
*SVN*
-* Added Extension extension to provide support for clean backtraces. [Nicholas Seckar]
+* Update Exception extension to show the first few framework frames in an application trace. [Nicholas Seckar]
+
+* Added Exception extension to provide support for clean backtraces. [Nicholas Seckar]
* Updated whiny nil to be more concise and useful. [Nicholas Seckar]
diff --git a/activesupport/lib/active_support/core_ext/exception.rb b/activesupport/lib/active_support/core_ext/exception.rb
index 323d97aa44..5a2d21590b 100644
--- a/activesupport/lib/active_support/core_ext/exception.rb
+++ b/activesupport/lib/active_support/core_ext/exception.rb
@@ -13,6 +13,12 @@ class Exception
end
def application_backtrace
- clean_backtrace.reject { |line| line =~ /(vendor|dispatch|ruby|script\/\w+)/ }
+ before_application_frame = true
+
+ clean_backtrace.reject do |line|
+ non_app_frame = !! (line =~ /vendor|dispatch|ruby|script\/\w+/)
+ before_application_frame = false unless non_app_frame
+ non_app_frame && ! before_application_frame
+ end
end
end \ No newline at end of file
diff --git a/activesupport/test/core_ext/exception_test.rb b/activesupport/test/core_ext/exception_test.rb
index 69990d4715..7f5e64bc9f 100644
--- a/activesupport/test/core_ext/exception_test.rb
+++ b/activesupport/test/core_ext/exception_test.rb
@@ -21,4 +21,18 @@ class ExceptionExtTests < Test::Unit::TestCase
assert_equal ['bhal.rb', 'rawh hid den stuff is not here', 'almost all'], e.clean_backtrace
end
+ def test_app_backtrace
+ Exception::TraceSubstitutions << [/\s*hidden.*/, '']
+ e = get_exception RuntimeError, 'RAWR', ['bhal.rb', ' vendor/file.rb some stuff', 'almost all']
+ assert_kind_of Exception, e
+ assert_equal ['bhal.rb', 'almost all'], e.application_backtrace
+ end
+
+ def test_app_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', 'bhal.rb', 'almost all'], e.application_backtrace
+ end
+
end \ No newline at end of file