Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raw error attribute in job model #84

Merged
merged 3 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/little_monster/core/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions lib/little_monster/core/job_orchrestator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
7 changes: 7 additions & 0 deletions spec/lib/little_monster/core/job_orchrestator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading