aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-03-23 11:48:10 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-03-23 11:48:10 +0000
commit3697df1dd2be6e51867bea4d6089f01f8f204f3c (patch)
tree6d529e1637b88b89d9436531bfef2be33c9b3f02 /activesupport/lib
parentd09e42cfe4b970c03402ab41e3eef95cd32fa4d3 (diff)
downloadrails-3697df1dd2be6e51867bea4d6089f01f8f204f3c.tar.gz
rails-3697df1dd2be6e51867bea4d6089f01f8f204f3c.tar.bz2
rails-3697df1dd2be6e51867bea4d6089f01f8f204f3c.zip
Improved error reporting especially around never shallowing exceptions. Debugging helpers should be much easier now #980 [Nicholas Seckar]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@984 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/object_and_class.rb7
-rw-r--r--activesupport/lib/active_support/dependencies.rb11
2 files changed, 14 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/core_ext/object_and_class.rb b/activesupport/lib/active_support/core_ext/object_and_class.rb
index eb54f79534..be486b0816 100644
--- a/activesupport/lib/active_support/core_ext/object_and_class.rb
+++ b/activesupport/lib/active_support/core_ext/object_and_class.rb
@@ -21,6 +21,13 @@ class Object #:nodoc:
!self
end
end
+
+ def suppress(*exception_classes)
+ begin yield
+ rescue Exception => e
+ raise unless exception_classes.any? {|cls| e.kind_of? cls}
+ end
+ end
end
class Class #:nodoc:
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb
index 9518dfab90..a189da189a 100644
--- a/activesupport/lib/active_support/dependencies.rb
+++ b/activesupport/lib/active_support/dependencies.rb
@@ -21,8 +21,6 @@ module Dependencies
require_or_load(file_name)
rescue LoadError
raise unless swallow_load_errors
- rescue Object => e
- raise ScriptError, "#{e.message}"
end
end
end
@@ -179,8 +177,8 @@ class Object #:nodoc:
begin
require_or_load(class_id.to_s.demodulize.underscore)
if Object.const_defined?(class_id) then return Object.const_get(class_id) else raise LoadError end
- rescue LoadError
- raise NameError, "uninitialized constant #{class_id}"
+ rescue LoadError => e
+ raise NameError.new("uninitialized constant #{class_id}").copy_blame!(e)
end
end
end
@@ -216,4 +214,9 @@ class Exception
return nil if blamed_files.empty?
"This error occured while loading the following files:\n #{blamed_files.join "\n "}"
end
+
+ def copy_blame!(exc)
+ @blamed_files = exc.blamed_files.clone
+ self
+ end
end