add error helper for controllers to generate error messages
This commit is contained in:
parent
ca2400c8f0
commit
d1032f6e6b
1 changed files with 11 additions and 0 deletions
11
lib/chiya_web/error.ex
Normal file
11
lib/chiya_web/error.ex
Normal 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
|
Loading…
Reference in a new issue