diff options
author | Cristian Bica <cristian.bica@gmail.com> | 2014-09-03 10:38:02 +0300 |
---|---|---|
committer | Cristian Bica <cristian.bica@gmail.com> | 2014-09-03 14:23:47 +0300 |
commit | 56f992fe150f9fc2396e31fe7391b4cf018f55dc (patch) | |
tree | ab80906fcdb25affbe43a5de0c2da3e938929759 | |
parent | a4de217ce586740284238d907153750c0ce3e263 (diff) | |
download | rails-56f992fe150f9fc2396e31fe7391b4cf018f55dc.tar.gz rails-56f992fe150f9fc2396e31fe7391b4cf018f55dc.tar.bz2 rails-56f992fe150f9fc2396e31fe7391b4cf018f55dc.zip |
Fix for double ActiveJob::DeserializationErorr
-rw-r--r-- | activejob/lib/active_job/arguments.rb | 10 | ||||
-rw-r--r-- | activejob/test/cases/rescue_test.rb | 5 |
2 files changed, 10 insertions, 5 deletions
diff --git a/activejob/lib/active_job/arguments.rb b/activejob/lib/active_job/arguments.rb index e54f4afbc7..9d4490b0fc 100644 --- a/activejob/lib/active_job/arguments.rb +++ b/activejob/lib/active_job/arguments.rb @@ -5,7 +5,7 @@ module ActiveJob class DeserializationError < StandardError attr_reader :original_exception - def initialize(e) + def initialize(e) #:nodoc: super ("Error while trying to deserialize arguments: #{e.message}") @original_exception = e set_backtrace e.backtrace @@ -30,6 +30,8 @@ module ActiveJob def deserialize(arguments) arguments.map { |argument| deserialize_argument(argument) } + rescue => e + raise DeserializationError.new(e) end private @@ -40,7 +42,7 @@ module ActiveJob when *TYPE_WHITELIST argument when Array - serialize(argument) + argument.map { |arg| serialize_argument(arg) } when Hash Hash[ argument.map { |key, value| [ serialize_hash_key(key), serialize_argument(value) ] } ] else @@ -51,14 +53,12 @@ module ActiveJob def deserialize_argument(argument) case argument when Array - deserialize(argument) + argument.map { |arg| deserialize_argument(arg) } when Hash Hash[ argument.map { |key, value| [ key, deserialize_argument(value) ] } ].with_indifferent_access else GlobalID::Locator.locate(argument) || argument end - rescue => e - raise DeserializationError.new(e) end def serialize_hash_key(key) diff --git a/activejob/test/cases/rescue_test.rb b/activejob/test/cases/rescue_test.rb index d9ea3c91d7..3af147383e 100644 --- a/activejob/test/cases/rescue_test.rb +++ b/activejob/test/cases/rescue_test.rb @@ -28,4 +28,9 @@ class RescueTest < ActiveSupport::TestCase assert_includes JobBuffer.values, 'DeserializationError original exception was Person::RecordNotFound' assert_not_includes JobBuffer.values, 'performed beautifully' end + + test "should not wrap DeserializationError in DeserializationError" do + RescueJob.enqueue [Person.new(404)] + assert_includes JobBuffer.values, 'DeserializationError original exception was Person::RecordNotFound' + end end |