diff options
author | Egor Kislitsyn <egor@kislitsyn.com> | 2020-06-01 15:48:51 +0400 |
---|---|---|
committer | Egor Kislitsyn <egor@kislitsyn.com> | 2020-06-01 15:48:51 +0400 |
commit | a7627bdc7ae67a5c103f968eea02d6b1cf1ef8da (patch) | |
tree | e12af401307cfc3120d50c01580cd959f3b2503a /lib/pleroma/web/admin_api/controllers/fallback_controller.ex | |
parent | decaa64f75f8bd69622fa5fba757f99719f09808 (diff) | |
parent | e96765df6b04fe5e9766271a9c62e559392758b2 (diff) | |
download | pleroma-a7627bdc7ae67a5c103f968eea02d6b1cf1ef8da.tar.gz |
Merge remote-tracking branch 'origin/develop' into global-status-expiration
Diffstat (limited to 'lib/pleroma/web/admin_api/controllers/fallback_controller.ex')
-rw-r--r-- | lib/pleroma/web/admin_api/controllers/fallback_controller.ex | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/pleroma/web/admin_api/controllers/fallback_controller.ex b/lib/pleroma/web/admin_api/controllers/fallback_controller.ex new file mode 100644 index 000000000..82965936d --- /dev/null +++ b/lib/pleroma/web/admin_api/controllers/fallback_controller.ex @@ -0,0 +1,31 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Web.AdminAPI.FallbackController do + use Pleroma.Web, :controller + + def call(conn, {:error, :not_found}) do + conn + |> put_status(:not_found) + |> json(%{error: dgettext("errors", "Not found")}) + end + + def call(conn, {:error, reason}) do + conn + |> put_status(:bad_request) + |> json(%{error: reason}) + end + + def call(conn, {:param_cast, _}) do + conn + |> put_status(:bad_request) + |> json(dgettext("errors", "Invalid parameters")) + end + + def call(conn, _) do + conn + |> put_status(:internal_server_error) + |> json(%{error: dgettext("errors", "Something went wrong")}) + end +end |