]> git.cworth.org Git - sup/commitdiff
explicitly load index version, for better error messages
authorWilliam Morgan <wmorgan-sup@masanjin.net>
Wed, 24 Jun 2009 13:10:19 +0000 (09:10 -0400)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Wed, 24 Jun 2009 13:45:14 +0000 (09:45 -0400)
Catching the LoadError was masking errors from not having dependent
library like xapian and gdbm. This change makes the error messages
reflect what's actually missing. Since we're adding index types at
roughly once every 3 years, an explicit list like this shouldn't be too
difficult to maintain.

lib/sup/index.rb

index 9ec0488502faef01312b5580d94495b3ca60d114..fb46eb053a02b871923e93281021441414e11683 100644 (file)
@@ -213,10 +213,10 @@ EOS
 end
 
 index_name = ENV['SUP_INDEX'] || $config[:index] || DEFAULT_INDEX
-begin
-  require "sup/#{index_name}_index"
-rescue LoadError
-  fail "invalid index name #{index_name.inspect}"
+case index_name
+  when "xapian"; require "sup/xapian_index"
+  when "ferret"; require "sup/ferret_index"
+  else fail "unknown index type #{index_name.inspect}"
 end
 Index = Redwood.const_get "#{index_name.capitalize}Index"
 Redwood::log "using index #{Index.name}"