2020-05-20 14:00:41 +00:00
|
|
|
# Pleroma: A lightweight social networking server
|
2023-01-02 20:38:50 +00:00
|
|
|
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
2020-05-20 14:00:41 +00:00
|
|
|
# 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)
|
2020-05-21 10:03:38 +00:00
|
|
|
|> json(%{error: dgettext("errors", "Not found")})
|
2020-05-20 14:00:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def call(conn, {:error, reason}) do
|
|
|
|
conn
|
|
|
|
|> put_status(:bad_request)
|
2020-05-21 10:03:38 +00:00
|
|
|
|> json(%{error: reason})
|
2020-05-20 14:00:41 +00:00
|
|
|
end
|
|
|
|
|
2020-06-20 10:53:57 +00:00
|
|
|
def call(conn, {:errors, errors}) do
|
|
|
|
conn
|
|
|
|
|> put_status(:bad_request)
|
|
|
|
|> json(%{errors: errors})
|
|
|
|
end
|
|
|
|
|
2020-05-20 14:00:41 +00:00
|
|
|
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)
|
2020-05-21 10:03:38 +00:00
|
|
|
|> json(%{error: dgettext("errors", "Something went wrong")})
|
2020-05-20 14:00:41 +00:00
|
|
|
end
|
|
|
|
end
|