memEx/lib/memex_web/controllers/error_json.ex

15 lines
390 B
Elixir
Raw Normal View History

2023-04-13 23:29:29 -04:00
defmodule MemexWeb.ErrorJSON do
2024-12-30 19:18:00 -05:00
use Gettext, backend: MemexWeb.Gettext
2023-04-13 23:29:29 -04:00
def render(template, _assigns) do
error_string =
case template do
"404.json" -> dgettext("errors", "not found")
"401.json" -> dgettext("errors", "unauthorized")
_other_path -> dgettext("errors", "internal server error")
end
%{errors: %{detail: error_string}}
end
end