Merge branch 'exclude-reblogs-from-admin-api-by-default' into 'develop'
[akkoma] / lib / pleroma / web / views / error_view.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ErrorView do
6 use Pleroma.Web, :view
7 require Logger
8
9 def render("404.json", _assigns) do
10 %{errors: %{detail: "Page not found"}}
11 end
12
13 def render("500.json", assigns) do
14 Logger.error("Internal server error: #{inspect(assigns[:reason])}")
15
16 if Pleroma.Config.get(:env) != :prod do
17 %{errors: %{detail: "Internal server error", reason: inspect(assigns[:reason])}}
18 else
19 %{errors: %{detail: "Internal server error"}}
20 end
21 end
22
23 # In case no render clause matches or no
24 # template is found, let's render it as 500
25 def template_not_found(_template, assigns) do
26 render("500.json", assigns)
27 end
28 end