Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch errors deserializing marshalled objects #907

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

afn
Copy link

@afn afn commented Apr 7, 2016

fixes #906

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 91.153% when pulling 5e922ea on afn:issue-906 into 401f43e on collectiveidea:master.

super
begin
super
rescue Exception => error

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend rescue => error because Exception is a little too greedy and catches, for example, CTRL-C-ing the process. Leaving out the exception class implies rescue StandardError => error.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately Ruby raises an Exception, not an Error, when attempting to
unmarshal a Delegator with no setobj :(

On Friday, April 15, 2016, Jack Danger Canty [email protected]
wrote:

In lib/delayed/psych_ext.rb
#907 (comment)
:

@@ -74,7 +74,11 @@ def visit_Psych_Nodes_Mapping(object) # rubocop:disable CyclomaticComplexity, Me
raise Delayed::DeserializationError, "DataMapper::ObjectNotFoundError, class: #{klass} (#{error.message})"
end
else

  •      super
    
  •      begin
    
  •        super
    
  •      rescue Exception => error
    

I recommend rescue => error because Exception is a little too greedy and
catches, for example, CTRL-C-ing the process. Leaving out the exception
class implies rescue StandardError => error.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
https://github.com/collectiveidea/delayed_job/pull/907/files/5e922eacee9dda00c4316badfce6d9edafcfe208#r59939272

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific error that can be caught?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could catch ScriptError instead; this is the superclass of NotImplementedError (the one that's thrown for this particular case) as well as SyntaxError and LoadError

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed this to catch ScriptError instead of Exception.

ScriptError is the superclass of NotImplementedError, SyntaxError, and
LoadError.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Worker crashes when there is an error deserializing the handler
4 participants