Improve Backend Error page

Mostly handle things properly when the front-end is missing

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-03-09 19:39:54 +01:00
parent 2133287e26
commit 57662aa690
49 changed files with 4551 additions and 4284 deletions

View File

@@ -7,8 +7,13 @@ defmodule Mobilizon.Web.ErrorView do
import Mobilizon.Web.Views.Utils
def render("404.html", %{conn: conn}) do
tags = Instance.build_tags()
inject_tags(tags, get_locale(conn))
with tags <- Instance.build_tags(),
{:ok, html} <- inject_tags(tags, get_locale(conn)) do
html
else
{:error, error} ->
return_error(conn, error)
end
end
def render("404.json", _assigns) do
@@ -38,12 +43,18 @@ defmodule Mobilizon.Web.ErrorView do
}
end
def render("500.html", _assigns) do
def render("500.html", assigns) do
Mobilizon.Config.instance_config()
|> Keyword.get(:default_language, "en")
|> Gettext.put_locale()
render("500_page.html", %{})
assigns =
assigns
|> Map.update(:details, [], & &1)
|> Map.put(:instance, Mobilizon.Config.instance_name())
|> Map.put(:contact, Mobilizon.Config.contact())
render("500_page.html", assigns)
end
# In case no render clause matches or no