Skip to content

Commit

Permalink
fix: use same read_action in handle_error and in work
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Aug 4, 2023
1 parent 47af61a commit 3cba396
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/transformers/define_schedulers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ defmodule AshOban.Transformers.DefineSchedulers do
end
end

handle_error = handle_error(trigger, resource, api)
handle_error = handle_error(trigger, resource, api, read_action)

work = work(trigger, worker, pro?, read_action, api)

Expand Down Expand Up @@ -313,15 +313,15 @@ defmodule AshOban.Transformers.DefineSchedulers do
)
end

defp handle_error(trigger, resource, api) do
defp handle_error(trigger, resource, api, read_action) do
if trigger.on_error do
# We look up the record again since we have exited any potential transaction we were in before
quote location: :keep do
def handle_error(error, primary_key, stacktrace) do
query()
|> Ash.Query.do_filter(primary_key)
|> Ash.Query.set_context(%{private: %{ash_oban?: true}})
|> Ash.Query.for_read(unquote(trigger.read_action))
|> Ash.Query.for_read(unquote(read_action))
|> unquote(api).read_one()
|> case do
{:ok, nil} ->
Expand Down

0 comments on commit 3cba396

Please sign in to comment.