lib/polyglot.rb in polyglot-0.2.2 vs lib/polyglot.rb in polyglot-0.2.3
- old
+ new
@@ -33,11 +33,16 @@
source_file, loader = Polyglot.find(*a, &b)
if (loader)
loader.load(source_file)
@loaded[a[0]] = true
else
- raise LoadError.new("Polyglot failed to load '#{a[0]}' either directly or using extensions #{@registrations.keys.sort.inspect}")
+ msg = "Failed to load #{a[0]} using extensions #{(@registrations.keys+["rb"]).sort*", "}"
+ if defined?(MissingSourceFile)
+ raise MissingSourceFile.new(msg, a[0])
+ else
+ raise LoadError.new(msg)
+ end
end
end
end
end
@@ -45,8 +50,13 @@
alias polyglot_original_require require
def require(*a, &b)
polyglot_original_require(*a, &b)
rescue LoadError => load_error
- Polyglot.load(*a, &b)
+ begin
+ Polyglot.load(*a, &b)
+ rescue
+ # Raise the original exception, possibly a MissingSourceFile with a path
+ raise load_error
+ end
end
end