-
-
Save jorgevilaca82/2b0569a8d550b1748355fdeed5eba7f2 to your computer and use it in GitHub Desktop.
How to rescue from Ecto.MultipleResultsError
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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