aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/dependencies.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/dependencies.rb')
-rw-r--r--activesupport/lib/active_support/dependencies.rb35
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