1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.MastodonAPI.FallbackController do
6 use Pleroma.Web, :controller
8 def call(conn, {:error, %Ecto.Changeset{} = changeset}) do
11 |> Ecto.Changeset.traverse_errors(fn {message, _opt} -> message end)
12 |> Enum.map_join(", ", fn {_k, v} -> v end)
15 |> put_status(:unprocessable_entity)
16 |> json(%{error: error_message})
19 def call(conn, {:error, :not_found}) do
20 render_error(conn, :not_found, "Record not found")
23 def call(conn, {:error, error_message}) do
25 |> put_status(:bad_request)
26 |> json(%{error: error_message})
31 |> put_status(:internal_server_error)
32 |> json(dgettext("errors", "Something went wrong"))