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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user