Skip to content

Commit

Permalink
Style cleanup to Job error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
bensheldon committed Sep 21, 2020
1 parent 0b3e0e6 commit 2f2c492
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/good_job/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ def perform
result, unhandled_error = execute

result_error = nil
result, result_error = nil, result if result.is_a?(Exception) # rubocop:disable Style/ParallelAssignment
if result.is_a?(Exception)
result = nil
result_error = result
end

job_error = unhandled_error ||
result_error ||
Expand All @@ -203,8 +206,9 @@ def perform

if unhandled_error && GoodJob.reperform_jobs_on_standard_error
save!
elsif GoodJob.preserve_job_records == true || (GoodJob.preserve_job_records == :on_unhandled_error && unhandled_error)
update!(finished_at: Time.current)
elsif GoodJob.preserve_job_records == true || (unhandled_error && GoodJob.preserve_job_records == :on_unhandled_error)
self.finished_at = Time.current
save!
else
destroy!
end
Expand Down

0 comments on commit 2f2c492

Please sign in to comment.