Update the diagnostics template skip the useless '<controller not set>' text.
Fix symbol extensions test case. Clean paths inside of exception messages and traces. Add Pathname.clean_within for cleaning all the paths inside of a string. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4158 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
62dc792a48
commit
e714b25723
@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* Update the diagnostics template skip the useless '<controller not set>' text. [Nicholas Seckar]
|
||||
|
||||
* CHANGED DEFAULT: Don't parse YAML input by default, but keep it available as an easy option [DHH]
|
||||
|
||||
* Add additional autocompleter options [aballai, Thomas Fuchs]
|
||||
|
@ -1,6 +1,8 @@
|
||||
<h1>
|
||||
<%=h @exception.class.to_s %> in
|
||||
<%=h (@request.parameters["controller"] || "<controller not set>").capitalize %>#<%=h @request.parameters["action"] || "<action not set>" %>
|
||||
<%=h @exception.class.to_s %>
|
||||
<% if @request.parameters['controller'] %>
|
||||
in <%=h @request.parameters['controller'].humanize %>Controller<% if @request.parameters['action'] %>#<%=h @request.parameters['action'] %><% end %>
|
||||
<% end %>
|
||||
</h1>
|
||||
<pre><%=h @exception.clean_message %></pre>
|
||||
|
||||
|
@ -1,5 +1,9 @@
|
||||
* SVN *
|
||||
|
||||
* Clean paths inside of exception messages and traces. [Nicholas Seckar]
|
||||
|
||||
* Add Pathname.clean_within for cleaning all the paths inside of a string. [Nicholas Seckar]
|
||||
|
||||
* provide an empty Dependencies::LoadingModule.load which prints deprecation warnings. Lets 1.0 applications function with .13-style environment.rb.
|
||||
|
||||
*1.3.0* (March 27th, 2005)
|
||||
|
@ -1,25 +1,30 @@
|
||||
class Exception
|
||||
alias :clean_message :message
|
||||
class Exception # :nodoc:
|
||||
def clean_message
|
||||
Pathname.clean_within message
|
||||
end
|
||||
|
||||
TraceSubstitutions = []
|
||||
FrameworkRegexp = /generated_code|vendor|dispatch|ruby|script\/\w+/
|
||||
FrameworkRegexp = /generated|vendor|dispatch|ruby|script\/\w+/
|
||||
|
||||
def clean_backtrace
|
||||
backtrace.collect do |line|
|
||||
TraceSubstitutions.inject(line) do |line, (regexp, sub)|
|
||||
Pathname.clean_within(TraceSubstitutions.inject(line) do |line, (regexp, sub)|
|
||||
line.gsub regexp, sub
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
def application_backtrace
|
||||
before_application_frame = true
|
||||
|
||||
clean_backtrace.reject do |line|
|
||||
non_app_frame = !! (line =~ FrameworkRegexp)
|
||||
trace = clean_backtrace.reject do |line|
|
||||
non_app_frame = (line =~ FrameworkRegexp)
|
||||
before_application_frame = false unless non_app_frame
|
||||
non_app_frame && ! before_application_frame
|
||||
end
|
||||
|
||||
# If we didn't find any application frames, return an empty app trace.
|
||||
before_application_frame ? [] : trace
|
||||
end
|
||||
|
||||
def framework_backtrace
|
||||
|
7
activesupport/lib/active_support/core_ext/pathname.rb
Normal file
7
activesupport/lib/active_support/core_ext/pathname.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'pathname'
|
||||
require File.dirname(__FILE__) + '/pathname/clean_within'
|
||||
|
||||
class Pathname#:nodoc:
|
||||
extend ActiveSupport::CoreExtensions::Pathname::CleanWithin
|
||||
end
|
||||
|
@ -0,0 +1,14 @@
|
||||
module ActiveSupport #:nodoc:
|
||||
module CoreExtensions #:nodoc:
|
||||
module Pathname #:nodoc:
|
||||
module CleanWithin
|
||||
# Clean the paths contained in the provided string.
|
||||
def clean_within(string)
|
||||
string.gsub(%r{[\w. ]+(/[\w. ]+)+(\.rb)?(\b|$)}) do |path|
|
||||
new(path).cleanpath
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -41,6 +41,25 @@ def test_framework_backtrace_with_before
|
||||
assert_kind_of Exception, e
|
||||
assert_equal ['vendor/file.rb some stuff', ' vendor/file.rb some stuff'], e.framework_backtrace
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
def test_backtrace_should_clean_paths
|
||||
Exception::TraceSubstitutions << [/\s*hidden.*/, '']
|
||||
e = get_exception RuntimeError, 'RAWR', ['a/b/c/../d/../../../bhal.rb', 'rawh hid den stuff is not here', 'almost all']
|
||||
assert_kind_of Exception, e
|
||||
assert_equal ['bhal.rb', 'rawh hid den stuff is not here', 'almost all'], e.clean_backtrace
|
||||
end
|
||||
|
||||
def test_clean_message_should_clean_paths
|
||||
Exception::TraceSubstitutions << [/\s*hidden.*/, '']
|
||||
e = get_exception RuntimeError, "I dislike a/z/x/../../b/y/../c", ['a/b/c/../d/../../../bhal.rb', 'rawh hid den stuff is not here', 'almost all']
|
||||
assert_kind_of Exception, e
|
||||
assert_equal "I dislike a/b/c", e.clean_message
|
||||
end
|
||||
|
||||
def test_app_trace_should_be_empty_when_no_app_frames
|
||||
Exception::TraceSubstitutions << [/\s*hidden.*/, '']
|
||||
e = get_exception RuntimeError, 'RAWR', ['vendor/file.rb some stuff', 'generated/bhal.rb', ' vendor/file.rb some stuff', 'generated/almost all']
|
||||
assert_kind_of Exception, e
|
||||
assert_equal [], e.application_backtrace
|
||||
end
|
||||
end
|
||||
|
8
activesupport/test/core_ext/symbol_test.rb
Normal file
8
activesupport/test/core_ext/symbol_test.rb
Normal file
@ -0,0 +1,8 @@
|
||||
require 'test/unit'
|
||||
require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/symbol'
|
||||
|
||||
class SymbolTests < Test::Unit::TestCase
|
||||
def test_to_proc
|
||||
assert_equal %w(one two three), [:one, :two, :three].map(&:to_s)
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user