Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F85710625
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/lib/pleroma/web/views/error_view.ex b/lib/pleroma/web/views/error_view.ex
index 86a1744b7..f4c04131c 100644
--- a/lib/pleroma/web/views/error_view.ex
+++ b/lib/pleroma/web/views/error_view.ex
@@ -1,21 +1,28 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
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
# template is found, let's render it as 500
def template_not_found(_template, assigns) do
render("500.json", assigns)
end
end
diff --git a/test/web/views/error_view_test.exs b/test/web/views/error_view_test.exs
index 16a0c8cef..d529fd2c3 100644
--- a/test/web/views/error_view_test.exs
+++ b/test/web/views/error_view_test.exs
@@ -1,24 +1,29 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ErrorViewTest do
use Pleroma.Web.ConnCase, async: true
# Bring render/3 and render_to_string/3 for testing custom views
import Phoenix.View
test "renders 404.json" do
assert render(Pleroma.Web.ErrorView, "404.json", []) == %{errors: %{detail: "Page not found"}}
end
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
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Sep 19, 1:18 AM (12 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1768592
Default Alt Text
(2 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment