elixir - How to pattern match Ecto query error -



elixir - How to pattern match Ecto query error -

like other functions in elixir (as ecto's own transactions), want pattern match handle potential errors ecto queries. this:

case repo.get!(user, id) {:ok, user} -> #do {:error, message} -> #pass error end

obviously not work, how can pattern match ecto errors ecto.notsingleresult , other potential query problems preload errors?

use repo.get homecoming value or nil. can pattern match on expected struct or utilize if-clauses. repo.get! raises on purpose (for cases expect struct there , not beingness there error).

elixir ecto

Comments

Popular posts from this blog

Using Android Volley to post an array to PHP -

python - How to add an model instance to a django queryset? -

angularjs - No 'Access-Control-Allow-Origin' error from local domain to public API -