Implement failure cases in fetch artist image background job
This commit is contained in:
@@ -3,8 +3,18 @@ defmodule MusicLibrary.Worker.FetchArtistImage do
|
|||||||
|
|
||||||
@impl Oban.Worker
|
@impl Oban.Worker
|
||||||
def perform(%Oban.Job{args: %{"id" => artist_id}}) do
|
def perform(%Oban.Job{args: %{"id" => artist_id}}) do
|
||||||
with {:ok, _artist_info} <- MusicLibrary.Artists.fetch_image(artist_id) do
|
case MusicLibrary.Artists.fetch_image(artist_id) do
|
||||||
:ok
|
{: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
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user