I a using delayed_job, and I am raising an exception this way :
config/initializers/custom_exceptions.rb
class RemoteLockerException < StandardError; end
class RemoteLockerDenied < StandardError; end
lib/instruction_request_job.rb
class InstructionRequestJob < Struct.new(:style, :request_id)
def perform
....
> connector = RemoteContainerServer::Connector.create!(remote_container)
> raise Exceptions::RemoteLockerDenied , "RemoteLockerDenied" if
> connector.nil?
....
> requestId = connector.request_job(user, remote_container)
> raise Exceptions::RemoteContainerException, "RemoteContainerException" if
> requestId.nil?
...
end
there is a hook for any exception raised, to trap ALL the errors
and do something according to the raised exception , i.e. :
def error(job, exception)
case exception
when "RemoteContainerDenied"
.. do something
when "RemoteContainerException"
.. do something else ......
end
end
I am new to 'exception raising' ... so I initially thought I could
trap the exception message : "RemoteLockerDenied" or
"RemoteContainerException" as case parameter exception
but it seems not working that way ...
when raised , I get #<NameError: uninitialized constant
InstructionRequestJob::Exceptions> which is the exception type, not
the message ... I may be ( surely) totally wrong ..... how should I
proceed ?
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.