- Add error bubbling. Search problems now display to the user.

This commit is contained in:
Jordan Sissel 2010-11-21 08:22:09 +00:00
parent 6714ab1036
commit daefbe986d
4 changed files with 18 additions and 3 deletions

View file

@ -75,7 +75,7 @@ class LogStash::Web::ElasticSearch
end
req.errback do
@logger.warn(["Query failed", params, req.response])
yield :failure
yield({ "error" => req.response })
end
end # def search
end

View file

@ -49,11 +49,21 @@ class LogStash::Web::Server < Sinatra::Base
count = params["count"] = (params["count"] or 50).to_i
offset = params["offset"] = (params["offset"] or 0).to_i
elasticsearch.search(params) do |@results|
#p instance_variables
if @results.include?("error")
body haml :"search/error", :layout => !request.xhr?
next
end
@hits = (@results["hits"]["hits"] rescue [])
@total = (@results["hits"]["total"] rescue 0)
@graphpoints = []
@results["facets"]["by_hour"]["entries"].each do |entry|
@graphpoints << [entry["key"], entry["count"]]
begin
@results["facets"]["by_hour"]["entries"].each do |entry|
@graphpoints << [entry["key"], entry["count"]]
end
rescue => e
puts e
end
if count and offset

View file

@ -0,0 +1,3 @@
#error
%h4 The query '#{params["q"]}' resulted the following error:
%pre&= @results["error"]

View file

@ -46,6 +46,8 @@ body
background-color: pink
border: 1px solid red
padding: 3px
pre
white-space: pre-wrap
#error h1
font-size: 130%
padding: 0