diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index e29ee00..b515352 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -19,7 +19,11 @@ class SearchController < ApplicationController end if @search.valid? - @search.search_for_user!(@user) + begin + @search.search_for_user!(@user) + rescue ThinkingSph::ConnectionError + flash[:error] = I18n.t 'controllers.search_controller.flasherrorsearchcontroller' + end end end diff --git a/app/models/search.rb b/app/models/search.rb index 3a10a6a..809d568 100644 --- a/app/models/search.rb +++ b/app/models/search.rb @@ -96,14 +96,9 @@ class Search query = Riddle.escape(words) # go go gadget search - self.results = [] - self.total_results = 0 - begin - self.results = ThinkingSphinx.search query, opts - self.total_results = self.results.total_entries - rescue => e - Rails.logger.info "Error from Sphinx: #{e.inspect}" - end + self.total_results = -1 + self.results = ThinkingSphinx.search query, opts + self.total_results = self.results.total_entries if self.page > self.page_count self.page = self.page_count @@ -132,5 +127,10 @@ class Search end end end + + rescue ThinkingSphinx::ConnectionError => e + self.results = [] + self.total_results = -1 + raise e end end diff --git a/config/locales/en.yml b/config/locales/en.yml index f153d30..e3be902 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -439,6 +439,7 @@ en: flashdeletedmessage: "Deleted message." search_controller: searchtitle: "Search" + flasherrorsearchcontroller: "Sorry, but the search engine is currently out of order" stories_controller: submitstorytitle: "Submit Story" editstorytitle: "Edit Story" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 1695e00..3d6c6e9 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -449,6 +449,7 @@ fr: flashdeletedmessage: "Message effacé." search_controller: searchtitle: "Rechercher" + flasherrorsearchcontroller: "Désolé mais le moteur de recherche est actuellement cassé" stories_controller: submitstorytitle: "Soumettre une info" editstorytitle: "Éditer une info"