lib/polyglot.rb in polyglot-0.2.6 vs lib/polyglot.rb in polyglot-0.2.7
- old
+ new
@@ -2,10 +2,12 @@
require 'pathname'
module Polyglot
@registrations ||= {} # Guard against reloading
@loaded ||= {}
+
+ class PolyglotLoadError < LoadError; end
def self.register(extension, klass)
extension = [extension] unless Enumerable === extension
extension.each{|e|
@registrations[e] = klass
@@ -39,11 +41,11 @@
else
msg = "Failed to load #{file} using extensions #{(@registrations.keys+["rb"]).sort*", "}"
if defined?(MissingSourceFile)
raise MissingSourceFile.new(msg, file)
else
- raise LoadError.new(msg)
+ raise PolyglotLoadError.new(msg)
end
end
end
end
end
@@ -54,10 +56,10 @@
def require(*a, &b)
polyglot_original_require(*a, &b)
rescue LoadError => load_error
begin
Polyglot.load(*a, &b)
- rescue LoadError
+ rescue Polyglot::PolyglotLoadError
# Raise the original exception, possibly a MissingSourceFile with a path
raise load_error
end
end
end