Integrate ActiveJob / DeliverLater / GlobalID with Rails

WIP.
How about we leave the rescue_from and on deserialization error we raise an ActionJob::DeserializationError in which we give the actual exception-- 
Cristian Bica

On Fri, Aug 15, 2014 at 7:06 PM, Aaron Patterson <notifications@github.com>
wrote:

>> @@ -0,0 +1,20 @@
>> +class RescueJob < ActiveJob::Base
>> +  class OtherError < StandardError; end
>> +
>> +  rescue_from(ArgumentError) do
> Maybe this sample code will drive home the point why I think `rescue_from` for handling argument deserialization is a bad idea:
> ```ruby
> class RescueJob < ActiveJob::Base
>   rescue_from(ActiveRecord::RecordNotFound) do
>     # Was the record not found when deserializing the
>     # arguments?  Or did I make a mistake in `perform`?
>     retry_now
>   end
>   def perform(person)
>     # oops, I meant friend_id, but I used parent_id, so this may
>     # generate a record not found error
>     Friend.find person.parent_id
>   end
> end
> ```
> If we want a way for dealing with deserialization errors, we should add a more specific way of doing that.  Maybe something like this:
> ```diff
> diff --git a/activejob/lib/active_job/execution.rb b/activejob/lib/active_job/execution.rb
> index 78ada3d..fbbc378 100644
> --- a/activejob/lib/active_job/execution.rb
> +++ b/activejob/lib/active_job/execution.rb
> @@ -11,7 +11,11 @@ module ActiveJob
>  
>      def execute(job_id, *serialized_args)
>        self.job_id    = job_id
> +      begin
>        self.arguments = Arguments.deserialize(serialized_args)
> +      rescue => e
> +        deserialization_error e
> +      end
>  
>        run_callbacks :perform do
>          perform *arguments
> @@ -23,5 +27,9 @@ module ActiveJob
>      def perform(*)
>        raise NotImplementedError
>      end
> +
> +    def deserialization_error(exception)
> +      raise exception
> +    end
>    end
>  end
> ```
> ---
> Reply to this email directly or view it on GitHub:
> https://github.com/rails/rails/pull/16485/files#r16300021