Commit 1f85c9c9 authored by lain's avatar lain

Merge branch 'feature/improve-error-logging' into 'develop'

logging: improve visibility into ISE errors

See merge request !845
parents 54f9e3d3 22e2ed23
Pipeline #8009 passed with stages
in 4 minutes and 40 seconds
......@@ -4,13 +4,20 @@
defmodule Pleroma.Web.ErrorView do
use Pleroma.Web, :view
require Logger
def render("404.json", _assigns) do
%{errors: %{detail: "Page not found"}}
end
def render("500.json", _assigns) do
%{errors: %{detail: "Internal server error"}}
def render("500.json", assigns) do
Logger.error("Internal server error: #{inspect(assigns[:reason])}")
if Mix.env() != :prod do
%{errors: %{detail: "Internal server error", reason: inspect(assigns[:reason])}}
else
%{errors: %{detail: "Internal server error"}}
end
end
# In case no render clause matches or no
......
......@@ -14,11 +14,16 @@ defmodule Pleroma.Web.ErrorViewTest do
test "render 500.json" do
assert render(Pleroma.Web.ErrorView, "500.json", []) ==
%{errors: %{detail: "Internal server error"}}
%{errors: %{detail: "Internal server error", reason: "nil"}}
end
test "render any other" do
assert render(Pleroma.Web.ErrorView, "505.json", []) ==
%{errors: %{detail: "Internal server error"}}
%{errors: %{detail: "Internal server error", reason: "nil"}}
end
test "render 500.json with reason" do
assert render(Pleroma.Web.ErrorView, "500.json", reason: "test reason") ==
%{errors: %{detail: "Internal server error", reason: "\"test reason\""}}
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment