fix(backend): handle ecto errors when fetching and create entities
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
f1084c101f
commit
89d1ee42f4
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue