sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit b6097e518d47e94adb5231451cba6ccbecb7cf00
parent 59f8fc2e4bc809d5dfc7c1af747879dae00539d8
Author: William Morgan <wmorgan-sup@masanjin.net>
Date:   Wed, 24 Jun 2009 09:10:19 -0400

explicitly load index version, for better error messages

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.

Diffstat:
M lib/sup/index.rb | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/sup/index.rb b/lib/sup/index.rb
@@ -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}"