2023-04-14 23:34:11 -04:00
|
|
|
defmodule CanneryWeb.ErrorJSON do
|
2024-10-26 15:36:12 -04:00
|
|
|
use Gettext, backend: CanneryWeb.Gettext
|
2023-04-14 23:34:11 -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
|