analytics/lib/plausible_web/plugs/error_handler.ex
hq1 c1a1d697a4
Partially revert #3661 - just keep the real errors wrapped, but don't display anything to the user (#3677)
* Revert "Remove unused RocketIcon"

This reverts commit c5e8d0c172.

* Revert "Display either hash or actual error message"

This reverts commit 0c091ab35f.

* Revert "Use ApiErrorNotice in funnels"

This reverts commit 5929de248e.

* Revert "Don't render "No data yet" when there's a NetworkError for example"

This reverts commit 70bee07632.

* Revert "Show the sinking shuttle notice whenever an API error occurs"

This reverts commit 9a62c8af2b.

* Revert "Add Hahash dependency"

This reverts commit b94207ea0a.

* Remove support hash
2024-01-09 17:17:42 +01:00

21 lines
591 B
Elixir

defmodule PlausibleWeb.Plugs.ErrorHandler do
@moduledoc """
A thin macro wrapper around Plug.ErrorHandler that adds Sentry context
containing a readable support hash presented to the users.
To be used in the user-facing APIs, so that we don't leak internal
server errors.
Usage: `use PlausibleWeb.Plugs.ErrorHandler`
"""
defmacro __using__(_) do
quote do
use Plug.ErrorHandler
@impl Plug.ErrorHandler
def handle_errors(conn, %{kind: kind, reason: reason}) do
json(conn, %{error: "internal server error"})
end
end
end
end