diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-23 11:53:40 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-23 11:53:40 +0000 |
commit | 373adc7f86f68f7b16d136835bb9254aaffd797f (patch) | |
tree | ead12d0a30ca9343ee8610bd6611b111c663ebcc /activesupport/lib | |
parent | 3697df1dd2be6e51867bea4d6089f01f8f204f3c (diff) | |
download | rails-373adc7f86f68f7b16d136835bb9254aaffd797f.tar.gz rails-373adc7f86f68f7b16d136835bb9254aaffd797f.tar.bz2 rails-373adc7f86f68f7b16d136835bb9254aaffd797f.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@985 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/load_error.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/load_error.rb b/activesupport/lib/active_support/core_ext/load_error.rb new file mode 100644 index 0000000000..42f2d42e78 --- /dev/null +++ b/activesupport/lib/active_support/core_ext/load_error.rb @@ -0,0 +1,34 @@ +class MissingSourceFile < LoadError + attr_reader :path + def initialize(message, path) + super(message) + @path = path + end + + def self.from_message(message) + REGEXPS.each do |regexp, capture| + match = regexp.match(message) + return MissingSourceFile.new(message, match[capture]) unless match.nil? + end + nil + end + + REGEXPS = [ + [/^no such file to load -- (.+)$/i, 1], + [/^Missing \w+ (file\s*)?([^\s]+.rb)$/i, 2], + [/^Missing API definition file in (.+)$/i, 1] + ] +end + +module ActiveSupport + module CoreExtensions + module LoadErrorExtensions + module LoadErrorClassMethods + def new(*args) + (self == LoadError && MissingSourceFile.from_message(args.first)) || super + end + end + ::LoadError.extend(LoadErrorClassMethods) + end + end +end
\ No newline at end of file |