Implement failure cases in fetch artist image background job

This commit is contained in:
Claudio Ortolina
2025-04-28 20:12:15 +01:00
parent f3e2b0e68a
commit 26be067750
+12 -2
View File
@@ -3,8 +3,18 @@ defmodule MusicLibrary.Worker.FetchArtistImage do
@impl Oban.Worker
def perform(%Oban.Job{args: %{"id" => artist_id}}) do
with {:ok, _artist_info} <- MusicLibrary.Artists.fetch_image(artist_id) do
:ok
case MusicLibrary.Artists.fetch_image(artist_id) do
{:ok, _artist_info} ->
:ok
{:error, :image_not_found} ->
{:cancel, :image_not_found}
{:error, :no_discogs_data} ->
{:cancel, :no_discogs_data}
error ->
error
end
end
end