Skip to content

FunctionClauseError: Meilisearch.Error.cast/1 #22

@cwc

Description

@cwc

We have occasionally encountered the following error in our application:

FunctionClauseError: no function clause matching in Meilisearch.Error.cast/1
  File "lib/meilisearch/error.ex", line 135, in Meilisearch.Error.cast/1
  File "lib/meilisearch/client.ex", line 58, in Meilisearch.Client.handle_response/1
  File "lib/meilisearch/search.ex", line 148, in Meilisearch.Search.search/3
  <snip>

It appears that for some reason, the body of the request to Meili is neither nil nor a map. I believe it is likely an error message - a binary - but there is no function clause for cast/1 in error.ex to handle this and return it to our application.

I believe this could be fixed by adding a clause to handle a binary body, by returning a Meilisearch.Error where the body is in the message key of the Error struct. I can open a PR to make this change if you like the idea.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions