Like other functions in elixir (as well as Ecto's own transactions), I want to pattern match to handle potential errors with Ecto queries. Like this:
case Repo.get!(User, id) do
{:ok, user} ->
#do something
{:error, message} ->
#pass the error
end
Obviously this does not work, but how can I pattern match Ecto errors like Ecto.NotSingleResult and other potential query problems like preload errors?