FunctionClauseError: No function clause matching
travcunn opened this issue · 4 comments
In one of our production systems, I am seeing the following in the logs hundreds of times. Should this exception be handled by the Elasticsearch Elixir client? The original function call is Elasticsearch.put_document
.
(elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3
** (FunctionClauseError) no function clause matching in Elasticsearch.Exception.build/2
(elasticsearch) lib/elasticsearch/exception.ex:35: Elasticsearch.Exception.build(%{"message" => nil}, nil)
(elasticsearch) lib/elasticsearch/exception.ex:22: Elasticsearch.Exception.exception/1
(elasticsearch) lib/elasticsearch.ex:389: Elasticsearch.format/1
Yes, this should be caught by the library. Do you know what the error payload Elasticsearch is returning looks like? I can see that it includes %{"message" => nil}
, but wondered if there's any more detail in the Elasticsearch response than that.
@travcunn it looks to me like you're not using the latest version of the library. lib/elasticsearch.ex:389
doesn't call Elasticsearch.format
anymore. Have you tried upgrading to the latest version?
I found out why this was happening in our system. There was a loop that was calling Elasticsearch.put_document
thousands of times. I would be interested in making an improvement to this project in such a way that unhandled errors just spit out raw HTTP errors so it is easier to debug Elasticsearch queries.
I got the same error
Elixir.FunctionClauseError: no function clause matching in Elasticsearch.Exception.build/2
File "lib/elasticsearch/exception.ex", line 35, in Elasticsearch.Exception.build/2
File "lib/elasticsearch/exception.ex", line 22, in Elasticsearch.Exception.exception/1
File "lib/elasticsearch.ex", line 389, in Elasticsearch.format/1
the argument to build/2
is
%{"message" => "Unable to connect to the server.", "ok" => false}
and nil