Current section

Files

Jump to
phoenix priv templates phx.gen.json fallback_controller.ex
Raw

priv/templates/phx.gen.json/fallback_controller.ex

defmodule <%= inspect context.web_module %>.FallbackController do
@moduledoc """
Translates controller action results into valid `Plug.Conn` responses.
See `Phoenix.Controller.action_fallback/1` for more details.
"""
use <%= inspect context.web_module %>, :controller
def call(conn, {:error, %Ecto.Changeset{} = changeset}) do
conn
|> put_status(:unprocessable_entity)
|> render(<%= inspect context.web_module %>.ChangesetView, "error.json", changeset: changeset)
end
def call(conn, {:error, :not_found}) do
conn
|> put_status(:not_found)
|> render(<%= inspect context.web_module %>.ErrorView, :"404")
end
end