Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of https://github.com/jorgemanrubia/delayed_job

* '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...
commit 6e8b218801f51bb48632909c7b8825a324367f45 2 parents 2293667 + 2b23b80
@bkeepers bkeepers authored
Showing with 9 additions and 1 deletion.
  1. +8 −0 lib/delayed/backend/shared_spec.rb
  2. +1 −1  lib/delayed/worker.rb
View
8 lib/delayed/backend/shared_spec.rb
@@ -345,6 +345,7 @@ def create_job(opts = {})
Delayed::Worker.max_run_time = old_max_run_time
end
end
+
end
context "worker prioritization" do
@@ -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
View
2  lib/delayed/worker.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.