catch sphinx errors

This commit is contained in:
joshua stein 2012-09-01 22:52:17 -05:00
parent a428dc31e7
commit 88894a66fc
1 changed files with 9 additions and 3 deletions

View File

@ -26,7 +26,7 @@ class Search
end
def to_url_params
[ :q, :what, :order ].map{|p| "#{p}=#{CGI.escape(self.send(p))}"
[ :q, :what, :order ].map{|p| "#{p}=#{CGI.escape(self.send(p).to_s)}"
}.join("&")
end
@ -63,8 +63,14 @@ class Search
query = self.q.gsub(/\//, "\\/")
# go go gadget search
@results = ThinkingSphinx.search query, opts
@total_results = @results.total_entries
@results = []
@total_results = 0
begin
@results = ThinkingSphinx.search query, opts
@total_results = @results.total_entries
rescue => e
Rails.logger.info "Error from Sphinx: #{e.inspect}"
end
# bind votes for both types