Skip to content

Commit

Permalink
- Add error bubbling. Search problems now display to the user.
Browse files Browse the repository at this point in the history
  • Loading branch information
jordansissel committed Nov 21, 2010
1 parent 6714ab1 commit daefbe9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/logstash/web/lib/elasticsearch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def search(params)
end
req.errback do
@logger.warn(["Query failed", params, req.response])
yield :failure
yield({ "error" => req.response })
end
end # def search
end
14 changes: 12 additions & 2 deletions lib/logstash/web/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions lib/logstash/web/views/search/error.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#error
%h4 The query '#{params["q"]}' resulted the following error:
%pre&= @results["error"]
2 changes: 2 additions & 0 deletions lib/logstash/web/views/style.sass
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit daefbe9

Please sign in to comment.