handling my custom exceptions , is that right ?

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

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 \+ &quot;, member: \#\{@member\_id\}  , ERROR: \#\{@error\_code\}&quot;
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 ?

Are you sure the exception passed to the error method is the one you
expected ?

Fred

solved ... not related to exception .. correctly passed and raised,
but rather related to a bad delayed_job struct definition

class InstructionRequestJob <
Struct.new(:param1, :param2, :param3, :error)

but I enqueued it w only 2 parameters :
Delayed::Job.enqueue InstructionRequestJob.new( param1, param2)

so got issue with the DJ :error catch...
writing : Delayed::Job.enqueue InstructionRequestJob.new( param1,
param2, params3) solved the issue :
   def error(job, exception)
     ..
     error_code = exception.error_code # or anything else stored in
the exception...
     ...
   end
catching correctly the raised exception ...

thanks a lot