Skip to content

Instantly share code, notes, and snippets.

@jorgevilaca82
Last active August 15, 2023 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorgevilaca82/2b0569a8d550b1748355fdeed5eba7f2 to your computer and use it in GitHub Desktop.
Save jorgevilaca82/2b0569a8d550b1748355fdeed5eba7f2 to your computer and use it in GitHub Desktop.
How to rescue from Ecto.MultipleResultsError
defmodule T do
import Ecto.Query
alias MyApp.Repo
def test() do
from(s in "users", select: [:id]) |> Repo.one()
rescue
Ecto.MultipleResultsError -> IO.puts("Sorry. Things didn't go well.")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment