-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
One would typically want to handle a multi in the following pattern:
{existing multi}
|> Ecto.Multi.merge(fn %{job: job} = multi ->
Ecto.Multi.new()
|> __MODULE__.requeue("requeue_job", job)
end)
|> MyApp.Repo.transaction()
|> case do
{:error, :non_failed_job} -> do_something
end
The above would also allow you to pass the error on to fallback controllers and such.
However, the way the requeue function is currently implimented, it does not just register an error on the multi, but rather returns an error. This forces one do add a non-elegant error handling block somewhere midstream something like the following.
|> Ecto.Multi.merge(fn %{job: job} = multi ->
Ecto.Multi.new()
|> __MODULE__.requeue("requeue_job", job)
|> case do
{:error, :non_failed_job} ->
Ecto.Multi.new()
|> Ecto.Multi.error("requeue_job", {:error, :non_failed_job})
any ->
any
end
end)
|> MyApp.Repo.transaction()
|> case do
{:error, :non_failed_job} -> do_something
end
gaggle
Metadata
Metadata
Assignees
Labels
No labels