diff --git a/lib/little_monster/core/job.rb b/lib/little_monster/core/job.rb index a6994cc..b01957f 100644 --- a/lib/little_monster/core/job.rb +++ b/lib/little_monster/core/job.rb @@ -92,7 +92,7 @@ def mock? end end - attr_accessor :id, :tags, :status, :retries, :current_action, :data, :error + attr_accessor :id, :tags, :status, :retries, :current_action, :data, :error, :raw_error attr_reader :orchrestator diff --git a/lib/little_monster/core/job_orchrestator.rb b/lib/little_monster/core/job_orchrestator.rb index 977c3f0..17cae76 100644 --- a/lib/little_monster/core/job_orchrestator.rb +++ b/lib/little_monster/core/job_orchrestator.rb @@ -182,6 +182,7 @@ def handle_error(error) end @job.error = @job.serialize_error error + @job.raw_error = error if error.is_a?(FatalTaskError) || error.is_a?(NameError) logger.debug 'error is fatal, aborting run' diff --git a/spec/lib/little_monster/core/job_orchrestator_spec.rb b/spec/lib/little_monster/core/job_orchrestator_spec.rb index 450de61..1275d16 100644 --- a/spec/lib/little_monster/core/job_orchrestator_spec.rb +++ b/spec/lib/little_monster/core/job_orchrestator_spec.rb @@ -626,6 +626,13 @@ subject.handle_error error expect(subject).to have_received(:do_retry).with error end + + it 'sets error and raw_error' do + error = LittleMonster::TaskError.new + subject.handle_error error + expect(subject.job.error).to eq(message: error.message, type: error.class.to_s, retry: subject.job.retries) + expect(subject.job.raw_error).to eq(error) + end end end