diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-20 10:51:10 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-20 10:51:10 +0000 |
commit | 98349f37a31979b04f01d8be59d0db83620abf24 (patch) | |
tree | e641b267c9dd447d33558f5bccf668d9e29719b2 /activesupport/lib/active_support | |
parent | 6a7fc51c6675786f4791c45edc1fac42ea6e3df9 (diff) | |
download | rails-98349f37a31979b04f01d8be59d0db83620abf24.tar.gz rails-98349f37a31979b04f01d8be59d0db83620abf24.tar.bz2 rails-98349f37a31979b04f01d8be59d0db83620abf24.zip |
Gives Rescues some Love #680
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@709 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/dependencies.rb | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index 0a9b8e1d3d..1aae239d71 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -100,7 +100,12 @@ module Dependencies end def load_file(file_path) - Controllers.module_eval(IO.read(file_path), file_path, 1) # Hard coded Controller line here!!! + begin + Controllers.module_eval(IO.read(file_path), file_path, 1) # Hard coded Controller line here!!! + rescue Object => exception + exception.blame_file! file_path + raise + end end end end @@ -125,4 +130,30 @@ class Object #:nodoc: end end end -end
\ No newline at end of file + def load(file, *extras) + begin super(file, *extras) + rescue Object => exception + exception.blame_file! file + raise + end + end + def require(file, *extras) + begin super(file, *extras) + rescue Object => exception + exception.blame_file! file + raise + end + end +end + +# Add file-blaming to exceptions +class Exception + def blame_file!(file) + (@blamed_files ||= []).unshift file + end + attr_reader :blamed_files + def describe_blame + return nil if blamed_files.empty? + "This error occured while loading the following files:\n #{blamed_files.join '\n '}" + end +end |