in my config/initializers , I created the file custom_exceptions.rb
in which I put all my custom exceptions
..
module Exceptions
class MyLockerException < StandardError
def initialize(msg, error_code , member_id )
super(msg)
@message = msg
@error_code = error_code
@member_id = member_id
end
def message
@message + ", member: #{@member_id} , ERROR: #{@error_code}"
end
def error_code
@error_code
end
def member_id
@member_id
end
end
...
I have a Delayed_job script , in which I raise the exceptions like
this :
...
raise Exceptions::MyLockerException.new("MyLockerException",
error_code, locker[:id], member[:id], ) if analysis.nil?
..
when the exception is raised , it's catch by the error method
def error(job, exception)
memberId = exception.member_id
but , I got an error => member_id is not defined in exception ...
why ? member_id is clearly defined in the class MyLockerException ,
isn't it ?
thanks for your feedback
--
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.