Permalink
Browse files

Fix deserialization error crash

DJ was crashing when unexpected exception has been raised from
YAML.load. Changed it to rescue all Exceptions and transform them to
DeserializationErrors.
  • Loading branch information...
1 parent 0333bf1 commit 78142d390533b4e47b78b21fba34b368f7fad4be @nazgob nazgob committed Jul 30, 2012
Showing with 7 additions and 1 deletion.
  1. +1 −1 lib/delayed/backend/base.rb
  2. +6 −0 lib/delayed/backend/shared_spec.rb
@@ -83,7 +83,7 @@ def payload_object=(object)
def payload_object
@payload_object ||= YAML.load(self.handler)
- rescue TypeError, LoadError, NameError, ArgumentError => e
+ rescue Exception => e
raise DeserializationError,
"Job failed to load: #{e.message}. Handler: #{handler.inspect}"
end
@@ -174,6 +174,12 @@ def create_job(opts = {})
YAML.should_receive(:load).and_raise(ArgumentError)
lambda { job.payload_object }.should raise_error(Delayed::DeserializationError)
end
+
+ it "should raise a DeserializationError when the YAML.load raises an unexpected error" do
+ job = described_class.new :handler => "--- !ruby/struct:GoingToRaiseArgError {}"
+ YAML.should_receive(:load).and_raise(Exception)
+ lambda { job.payload_object }.should raise_error(Delayed::DeserializationError)
+ end
end
describe "reserve" do

0 comments on commit 78142d3

Please sign in to comment.