From 2f2c492d3ad08d2af2e8bfa84e245633ae3e56ed Mon Sep 17 00:00:00 2001 From: Ben Sheldon Date: Mon, 21 Sep 2020 07:19:04 -0700 Subject: [PATCH] Style cleanup to Job error handling --- lib/good_job/job.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/good_job/job.rb b/lib/good_job/job.rb index 7bc67a7ea..36e4dd0af 100644 --- a/lib/good_job/job.rb +++ b/lib/good_job/job.rb @@ -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 || @@ -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