Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/elasticsearch/exception.ex
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ defmodule Elasticsearch.Exception do
]
end

defp build(%{"found" => false}, query) do
[
status: nil,
line: nil,
col: nil,
message: nil,
type: "document_not_found",
query: query
]
end

defp build(error, query) when is_binary(error) do
binary_error(error, query)
end
Expand Down
15 changes: 15 additions & 0 deletions test/elasticsearch/exception_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,20 @@ defmodule Elasticsearch.ExceptionTest do
query: nil
)
end

# See issue: https://github.com/infinitered/elasticsearch-elixir/issues/33
@tag :regression
test "understands the document_not_found error" do
assert %Exception{type: "document_not_found", message: nil, query: nil} =
Exception.exception(
response: %{
"_id" => "123",
"_index" => "index-name",
"_type" => "_doc",
"found" => false
},
query: nil
)
end
end
end