Permalink
Browse files

delay backtrace scrubbing until we actually raise an exception. fixes #…

  • Loading branch information...
1 parent cea06a8 commit ea7f50863d3a1e58a28921b15da3927ad7d18f4a @tenderlove tenderlove committed Jul 29, 2011
Showing with 4 additions and 7 deletions.
  1. +4 −7 activesupport/lib/active_support/dependencies.rb
View
11 activesupport/lib/active_support/dependencies.rb
@@ -478,10 +478,6 @@ def load_missing_constant(from_mod, const_name)
qualified_name = qualified_name_for from_mod, const_name
path_suffix = qualified_name.underscore
- trace = caller.reject {|l| l.starts_with? __FILE__ }
- name_error = NameError.new("uninitialized constant #{qualified_name}")
- name_error.set_backtrace(trace)
-
file_path = search_for_file(path_suffix)
if file_path && ! loaded.include?(File.expand_path(file_path)) # We found a matching file to load
@@ -500,11 +496,12 @@ def load_missing_constant(from_mod, const_name)
return parent.const_missing(const_name)
rescue NameError => e
raise unless e.missing_name? qualified_name_for(parent, const_name)
- raise name_error
end
- else
- raise name_error
end
+
+ raise NameError,
+ "uninitialized constant #{qualified_name}",
+ caller.reject {|l| l.starts_with? __FILE__ }
end
# Remove the constants that have been autoloaded, and those that have been

0 comments on commit ea7f508

Please sign in to comment.