Changeset 984
- Timestamp:
- 03/23/05 11:48:10 (3 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/dependencies.rb (modified) (2 diffs)
- trunk/actionpack/lib/action_controller/helpers.rb (modified) (2 diffs)
- trunk/actionpack/lib/action_controller/routing.rb (modified) (1 diff)
- trunk/actionpack/lib/action_controller/templates/rescues/_request_and_response.rhtml (modified) (1 diff)
- trunk/actionpack/lib/action_view/helpers/url_helper.rb (modified) (1 diff)
- trunk/actionwebservice/lib/action_web_service/container/action_controller_container.rb (modified) (2 diffs)
- trunk/activesupport/lib/active_support/core_ext/object_and_class.rb (modified) (1 diff)
- trunk/activesupport/lib/active_support/dependencies.rb (modified) (3 diffs)
- trunk/activesupport/test/core_ext/object_and_class_ext_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r980 r984 1 1 *SVN* 2 3 * Improved error reporting especially around never shallowing exceptions. Debugging helpers should be much easier now #980 [Nicholas Seckar] 2 4 3 5 * Fixed Toggle.display in prototype.js #902 [Lucas Carlson] trunk/actionpack/lib/action_controller/dependencies.rb
r780 r984 72 72 begin 73 73 require_dependency(dependency.to_s) 74 rescue LoadError 75 raise LoadError , "Missing #{layer} #{dependency}.rb"74 rescue LoadError => e 75 raise LoadError.new("Missing #{layer} #{dependency}.rb").copy_blame!(e) 76 76 rescue Object => exception 77 77 exception.blame_file! "=> #{layer} #{dependency}.rb" … … 84 84 inherited_without_model(child) 85 85 return if child.controller_name == "application" # otherwise the ApplicationController in Rails will include itself 86 model_name = child.controller_name.singularize 86 87 begin 87 child.model(child.controller_name.singularize) 88 rescue NameError, LoadError 89 # No neither singular or plural model available for this controller 88 require_dependency model_name 89 child.model model_name 90 rescue MissingSourceFile => e 91 raise unless e.path == model_name + '.rb' 90 92 end 91 93 end trunk/actionpack/lib/action_controller/helpers.rb
r780 r984 53 53 file_name = arg.to_s.underscore + '_helper' 54 54 class_name = file_name.camelize 55 55 56 56 begin 57 57 require_dependency(file_name) 58 58 rescue LoadError => load_error 59 59 requiree = / -- (.*?)(\.rb)?$/.match(load_error).to_a[1] 60 raise LoadError, requiree == file_name ? "Missing helper file helpers/#{file_name}.rb" : "Can't load file: #{requiree}" 60 msg = (requiree == file_name) ? "Missing helper file helpers/#{file_name}.rb" : "Can't load file: #{requiree}" 61 raise LoadError.new(msg).copy_blame!(load_error) 61 62 end 62 63 … … 91 92 def inherited(child) 92 93 inherited_without_helper(child) 93 begin 94 child.helper(child.controller_path) 95 rescue ArgumentError, LoadError 96 # No default helper available for this controller 94 begin child.helper(child.controller_path) 95 rescue MissingSourceFile => e 96 raise unless e.path == "helpers/#{child.controller_path}_helper.rb" 97 97 end 98 98 end trunk/actionpack/lib/action_controller/routing.rb
r976 r984 313 313 require_dependency(route_file) if route_file 314 314 rescue LoadError, ScriptError => e 315 raise RoutingError , "Cannot load config/routes.rb:\n #{e.message}"315 raise RoutingError.new("Cannot load config/routes.rb:\n #{e.message}").copy_blame!(e) 316 316 ensure # Ensure that there is at least one route: 317 317 connect(':controller/:action/:id', :action => 'index', :id => nil) if @routes.empty? trunk/actionpack/lib/action_controller/templates/rescues/_request_and_response.rhtml
r713 r984 1 <% if @exception.blamed_files && !@exception.blamed_files.empty? %> 2 <a href="#" onclick="document.getElementById('blame_trace').style.display='block'; return false;">Show blamed files</a> 3 <pre id="blame_trace" style="display:none"><code><%=h @exception.describe_blame %></code></pre> 1 <% unless @exception.blamed_files.blank? %> 2 <% if (hide = @exception.blamed_files.length > 8) %> 3 <a href="#" onclick="document.getElementById('blame_trace').style.display='block'; return false;">Show blamed files</a> 4 <% end %> 5 <pre id="blame_trace" <%='style="display:none"' if hide %>><code><%=h @exception.describe_blame %></code></pre> 4 6 <% end %> 5 7 trunk/actionpack/lib/action_view/helpers/url_helper.rb
r976 r984 22 22 # link_to "Delete this page", { :action => "destroy", :id => @page.id }, :confirm => "Are you sure?" 23 23 def link_to(name, options = {}, html_options = nil, *parameters_for_method_reference) 24 html_options = (html_options || {}).s tringify_keys24 html_options = (html_options || {}).symbolize_keys 25 25 convert_confirm_option_to_javascript!(html_options) 26 26 if options.is_a?(String) trunk/actionwebservice/lib/action_web_service/container/action_controller_container.rb
r800 r984 65 65 rescue LoadError => load_error 66 66 requiree = / -- (.*?)(\.rb)?$/.match(load_error).to_a[1] 67 raise LoadError, requiree == file_name ? "Missing API definition file in apis/#{file_name}.rb" : "Can't load file: #{requiree}" 67 msg = requiree == file_name ? "Missing API definition file in apis/#{file_name}.rb" : "Can't load file: #{requiree}" 68 raise LoadError.new(msg).copy_blame!(load_error) 68 69 end 69 70 klass = nil … … 84 85 def inherited(child) 85 86 inherited_without_api(child) 86 child.web_service_api(child.controller_path) 87 rescue Exception => e 87 begin child.web_service_api(child.controller_path) 88 rescue MissingSourceFile => e 89 raise unless e.path == "apis/#{child.controller_path}_api.rb" 90 end 88 91 end 89 92 end trunk/activesupport/lib/active_support/core_ext/object_and_class.rb
r857 r984 22 22 end 23 23 end 24 25 def suppress(*exception_classes) 26 begin yield 27 rescue Exception => e 28 raise unless exception_classes.any? {|cls| e.kind_of? cls} 29 end 30 end 24 31 end 25 32 trunk/activesupport/lib/active_support/dependencies.rb
r817 r984 22 22 rescue LoadError 23 23 raise unless swallow_load_errors 24 rescue Object => e25 raise ScriptError, "#{e.message}"26 24 end 27 25 end … … 180 178 require_or_load(class_id.to_s.demodulize.underscore) 181 179 if Object.const_defined?(class_id) then return Object.const_get(class_id) else raise LoadError end 182 rescue LoadError 183 raise NameError , "uninitialized constant #{class_id}"180 rescue LoadError => e 181 raise NameError.new("uninitialized constant #{class_id}").copy_blame!(e) 184 182 end 185 183 end … … 217 215 "This error occured while loading the following files:\n #{blamed_files.join "\n "}" 218 216 end 217 218 def copy_blame!(exc) 219 @blamed_files = exc.blamed_files.clone 220 self 221 end 219 222 end trunk/activesupport/test/core_ext/object_and_class_ext_test.rb
r624 r984 20 20 end 21 21 end 22 23 class ObjectTests < Test::Unit::TestCase 24 def test_suppress_re_raises 25 assert_raises(LoadError) { suppress(ArgumentError) {raise LoadError} } 26 end 27 def test_suppress_supresses 28 suppress(ArgumentError) { raise ArgumentError } 29 suppress(LoadError) { raise LoadError } 30 suppress(LoadError, ArgumentError) { raise LoadError } 31 suppress(LoadError, ArgumentError) { raise ArgumentError } 32 end 33 end