0cf96f88be
- Add FallbackController for proper 404 JSON responses on missing resources - Add non-bang get_source/1 and get_media_item/1 for safe lookups - Fix Task JSON encoder: remove Repo.preload call (not available in encoder scope), handle NotLoaded associations by returning nil - Fix media item index: use list_media_items_for_source/1 instead of list_pending_media_items_for/1 which had overly restrictive filtering - Add missing extras_directory to test config - All 1007 tests pass
18 lines
451 B
Elixir
18 lines
451 B
Elixir
defmodule PinchflatWeb.Api.V1.FallbackController do
|
|
@moduledoc """
|
|
Translates controller failures into JSON error responses.
|
|
"""
|
|
use PinchflatWeb, :controller
|
|
|
|
def call(conn, {:error, :not_found}) do
|
|
conn
|
|
|> put_status(:not_found)
|
|
|> json(%{errors: %{detail: "Not found"}})
|
|
end
|
|
|
|
def call(conn, %Ecto.NoResultsError{} = _error) do
|
|
conn
|
|
|> put_status(:not_found)
|
|
|> json(%{errors: %{detail: "Not found"}})
|
|
end
|
|
end |