In the following, iteration over ['a', nil, 'c']
will fail at nil
since you cannot do nil + 'd'
. I would like to rescue that message, modify it, and pass it on to another method that stores the error.
number = 0
begin
['a', nil, 'c'].each_with_index do |entry, i|
entry + 'd'
number = i
end
rescue => e
e.message="#{e.message} (happened at entry: #{number})"
store_exception(e)
end
The problem is, the method message=
does not exists. How do I do it?