Skip to content

Commit

Permalink
delay backtrace scrubbing until we actually raise an exception. fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Jul 29, 2011
1 parent d13df74 commit 61c5c3d
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions activesupport/lib/active_support/dependencies.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -479,10 +479,6 @@ def load_missing_constant(from_mod, const_name)
qualified_name = qualified_name_for from_mod, const_name qualified_name = qualified_name_for from_mod, const_name
path_suffix = qualified_name.underscore 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) file_path = search_for_file(path_suffix)


if file_path && ! loaded.include?(File.expand_path(file_path)) # We found a matching file to load if file_path && ! loaded.include?(File.expand_path(file_path)) # We found a matching file to load
Expand All @@ -501,11 +497,12 @@ def load_missing_constant(from_mod, const_name)
return parent.const_missing(const_name) return parent.const_missing(const_name)
rescue NameError => e rescue NameError => e
raise unless e.missing_name? qualified_name_for(parent, const_name) raise unless e.missing_name? qualified_name_for(parent, const_name)
raise name_error
end end
else
raise name_error
end end

raise NameError,
"uninitialized constant #{qualified_name}",
caller.reject {|l| l.starts_with? __FILE__ }
end end


# Remove the constants that have been autoloaded, and those that have been # Remove the constants that have been autoloaded, and those that have been
Expand Down

0 comments on commit 61c5c3d

Please sign in to comment.