Phoenix 404 Confusion

I was a bit confused by getting:

** (Ecto.NoResultsError) expected at least one result but got none in query:

When I queried for a non existent id like so:

product = Repo.get!(Product, id)

phoenix_ecto implements a protocol that should return a 404 instead.

defimpl Plug.Exception, for: Ecto.NoResultsError do  
  def status(_), do: 404

Turns out that its only used in the prod environment. If you want to see how it works in dev you need to set debug_errors: false in your config/dev.exs.

Though setting that you'll lose all the pretty errors. But nice to know if you want to look at something similar to production environment.