mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 16:40:29 +00:00
Merge branch 'feature/improve-error-logging' into 'develop'
logging: improve visibility into ISE errors See merge request pleroma/pleroma!845
This commit is contained in:
commit
1f85c9c9c7
2 changed files with 16 additions and 4 deletions
|
@ -4,13 +4,20 @@
|
||||||
|
|
||||||
defmodule Pleroma.Web.ErrorView do
|
defmodule Pleroma.Web.ErrorView do
|
||||||
use Pleroma.Web, :view
|
use Pleroma.Web, :view
|
||||||
|
require Logger
|
||||||
|
|
||||||
def render("404.json", _assigns) do
|
def render("404.json", _assigns) do
|
||||||
%{errors: %{detail: "Page not found"}}
|
%{errors: %{detail: "Page not found"}}
|
||||||
end
|
end
|
||||||
|
|
||||||
def render("500.json", _assigns) do
|
def render("500.json", assigns) do
|
||||||
%{errors: %{detail: "Internal server error"}}
|
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
|
end
|
||||||
|
|
||||||
# In case no render clause matches or no
|
# In case no render clause matches or no
|
||||||
|
|
|
@ -14,11 +14,16 @@ defmodule Pleroma.Web.ErrorViewTest do
|
||||||
|
|
||||||
test "render 500.json" do
|
test "render 500.json" do
|
||||||
assert render(Pleroma.Web.ErrorView, "500.json", []) ==
|
assert render(Pleroma.Web.ErrorView, "500.json", []) ==
|
||||||
%{errors: %{detail: "Internal server error"}}
|
%{errors: %{detail: "Internal server error", reason: "nil"}}
|
||||||
end
|
end
|
||||||
|
|
||||||
test "render any other" do
|
test "render any other" do
|
||||||
assert render(Pleroma.Web.ErrorView, "505.json", []) ==
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue