search: catch sphinx errors gracefully and show an error - merged with i18n
This commit is contained in:
parent
412b93babd
commit
462080150f
|
@ -19,7 +19,11 @@ class SearchController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
if @search.valid?
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -96,14 +96,9 @@ class Search
|
||||||
query = Riddle.escape(words)
|
query = Riddle.escape(words)
|
||||||
|
|
||||||
# go go gadget search
|
# go go gadget search
|
||||||
self.results = []
|
self.total_results = -1
|
||||||
self.total_results = 0
|
self.results = ThinkingSphinx.search query, opts
|
||||||
begin
|
self.total_results = self.results.total_entries
|
||||||
self.results = ThinkingSphinx.search query, opts
|
|
||||||
self.total_results = self.results.total_entries
|
|
||||||
rescue => e
|
|
||||||
Rails.logger.info "Error from Sphinx: #{e.inspect}"
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.page > self.page_count
|
if self.page > self.page_count
|
||||||
self.page = self.page_count
|
self.page = self.page_count
|
||||||
|
@ -132,5 +127,10 @@ class Search
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
rescue ThinkingSphinx::ConnectionError => e
|
||||||
|
self.results = []
|
||||||
|
self.total_results = -1
|
||||||
|
raise e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -439,6 +439,7 @@ en:
|
||||||
flashdeletedmessage: "Deleted message."
|
flashdeletedmessage: "Deleted message."
|
||||||
search_controller:
|
search_controller:
|
||||||
searchtitle: "Search"
|
searchtitle: "Search"
|
||||||
|
flasherrorsearchcontroller: "Sorry, but the search engine is currently out of order"
|
||||||
stories_controller:
|
stories_controller:
|
||||||
submitstorytitle: "Submit Story"
|
submitstorytitle: "Submit Story"
|
||||||
editstorytitle: "Edit Story"
|
editstorytitle: "Edit Story"
|
||||||
|
|
|
@ -449,6 +449,7 @@ fr:
|
||||||
flashdeletedmessage: "Message effacé."
|
flashdeletedmessage: "Message effacé."
|
||||||
search_controller:
|
search_controller:
|
||||||
searchtitle: "Rechercher"
|
searchtitle: "Rechercher"
|
||||||
|
flasherrorsearchcontroller: "Désolé mais le moteur de recherche est actuellement cassé"
|
||||||
stories_controller:
|
stories_controller:
|
||||||
submitstorytitle: "Soumettre une info"
|
submitstorytitle: "Soumettre une info"
|
||||||
editstorytitle: "Éditer une info"
|
editstorytitle: "Éditer une info"
|
||||||
|
|
Loading…
Reference in a new issue