Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* 'master' of https://github.com/jorgemanrubia/delayed_job:
  Changed the way the error message is composed when a job fails. Whith the previous implementation, if the raised error has a nil message, it will fail with a `<NoMethodError: undefined method '+' for nil:NilClass>`. Now it is using normal Ruby interpolation that will default to an empty String with nil messages.
  • Loading branch information
bkeepers committed Nov 12, 2010
2 parents 2293667 + 2b23b80 commit 6e8b218
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/delayed/backend/shared_spec.rb
Expand Up @@ -345,6 +345,7 @@ def create_job(opts = {})
Delayed::Worker.max_run_time = old_max_run_time
end
end

end

context "worker prioritization" do
Expand Down Expand Up @@ -433,6 +434,13 @@ def create_job(opts = {})

(Delayed::Job.db_time_now + 99.minutes - @job.run_at).abs.should < 1
end

it "should not fail when the triggered error doesn't have a message" do
error_with_nil_message = StandardError.new
error_with_nil_message.stub!(:message).and_return nil
@job.stub!(:invoke_job).and_raise error_with_nil_message
lambda{@worker.run(@job)}.should_not raise_error
end
end

context "reschedule" do
Expand Down
2 changes: 1 addition & 1 deletion lib/delayed/worker.rb
Expand Up @@ -153,7 +153,7 @@ def say(text, level = Logger::INFO)
protected

def handle_failed_job(job, error)
job.last_error = error.message + "\n" + error.backtrace.join("\n")
job.last_error = "{#{error.message}\n#{error.backtrace.join('\n')}"
say "#{job.name} failed with #{error.class.name}: #{error.message} - #{job.attempts} failed attempts", Logger::ERROR
reschedule(job)
end
Expand Down

0 comments on commit 6e8b218

Please sign in to comment.