collectiveidea/delayed_job — pull request #685 by tompave (2014-08-17 12:17:42+00:00)
Title: Improved error reporting when deserializing a non-existent record

**DelayedJob** raises an overly generic `Delayed::DeserializationError` when it tries to load a serialized record that does not exist in the DB.
This situation can come to be because of a serialization error, or because the record has been deleted since the job was enqueued.

The error is raised because the default **YAML** behaviour of loading an object is [patched](https://github.com/collectiveidea/delayed_job/blob/master/lib/delayed/psych_ext.rb#L39) to call `klass.find(id)` if the serialized object comes from a recognized persistence library (e.g. **ActiveRecord**).

There have already been discussions about this behaviour: [here](https://github.com/collectiveidea/delayed_job/pull/231), [here](https://github.com/collectiveidea/delayed_job/pull/282) and [here](https://github.com/collectiveidea/delayed_job/pull/296).
It seems like the **DJ** leads have a strong opinion on this design decision, and no patch has been merged in yet.

I'm not here to argue with the current behaviour and its implications and side effects, but I think we can do something about the error messages to make it clearer what is going on.

This PR adds more descriptive error messages, borrowing from what has already been done [here](https://github.com/collectiveidea/delayed_job/blob/master/lib/delayed/serialization/active_record.rb#L9).