2019-09-02 14:29:19 +03:00
|
|
|
defmodule PlausibleWeb.ControllerHelpers do
|
|
|
|
import Plug.Conn
|
|
|
|
import Phoenix.Controller
|
|
|
|
|
|
|
|
def render_error(conn, status, message) do
|
|
|
|
conn
|
|
|
|
|> put_status(status)
|
|
|
|
|> put_view(PlausibleWeb.ErrorView)
|
2023-05-16 11:52:17 +03:00
|
|
|
|> render("#{status}.html", message: message, layout: error_layout())
|
2019-09-02 14:29:19 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def render_error(conn, status) do
|
|
|
|
conn
|
|
|
|
|> put_status(status)
|
|
|
|
|> put_view(PlausibleWeb.ErrorView)
|
2023-05-16 11:52:17 +03:00
|
|
|
|> render("#{status}.html", layout: error_layout())
|
2019-09-02 14:29:19 +03:00
|
|
|
end
|
2023-05-16 11:52:17 +03:00
|
|
|
|
|
|
|
defp error_layout,
|
|
|
|
do: Application.get_env(:plausible, PlausibleWeb.Endpoint)[:render_errors][:layout]
|
2019-09-02 14:29:19 +03:00
|
|
|
end
|