Repo.all and no_return

These are the specs on Ecto 2.0.1 for Repo.all:

> all(queryable :: Ecto.Query.t, opts :: Keyword.t) ::
>   [Ecto.Schema.t] |
>   no_return
> 
> Fetches all entries from the data store matching the given query.
> 
> May raise [ `Ecto.QueryError` ](https://hexdocs.pm/ecto/2.0.1/Ecto.QueryError.html) if query validation fails.

Can someone clarify the usage of no_return in elixir/erlang… and specifically, how to pattern match against it if used in a case statement for Repo.all(queryable).

no_return() means that the function may in fact not return. Most typically this would be in the case of an un-caught exception. If its important, then you might want to rescue Ecto.QueryError as noted in your extract above.

1 Like