From 89d1ee42f4577650ebf9b996a518019b2e0f373c Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 5 Dec 2023 08:06:16 +0100 Subject: [PATCH] fix(backend): handle ecto errors when fetching and create entities Signed-off-by: Thomas Citharel --- lib/federation/activity_pub/fetcher.ex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/federation/activity_pub/fetcher.ex b/lib/federation/activity_pub/fetcher.ex index 97166baa2..288c4a394 100644 --- a/lib/federation/activity_pub/fetcher.ex +++ b/lib/federation/activity_pub/fetcher.ex @@ -42,7 +42,7 @@ defmodule Mobilizon.Federation.ActivityPub.Fetcher do end @spec fetch_and_create(String.t(), Keyword.t()) :: - {:ok, map(), struct()} | {:error, atom()} | :error + {:ok, map(), struct()} | {:error, atom()} | {:error, Ecto.Changeset.t()} | :error def fetch_and_create(url, options \\ []) do case fetch(url, options) do {:ok, data} when is_map(data) -> @@ -61,6 +61,9 @@ defmodule Mobilizon.Federation.ActivityPub.Fetcher do {:error, error} when is_atom(error) -> {:error, error} + {:error, %Ecto.Changeset{} = err} -> + {:error, err} + :error -> {:error, :transmogrifier_error} end