add error helper for controllers to generate error messages

This commit is contained in:
Inhji 2023-03-14 23:48:00 +01:00
parent ca2400c8f0
commit d1032f6e6b

11
lib/chiya_web/error.ex Normal file
View file

@ -0,0 +1,11 @@
defmodule ChiyaWeb.Error do
import Plug.Conn, only: [put_status: 2]
import Phoenix.Controller, only: [put_view: 2, render: 3]
def render_error(conn, :not_found, assigns \\ []) do
conn
|> put_status(:not_found)
|> put_view(ChiyaWeb.ErrorHTML)
|> render("404.html", assigns)
end
end