In my call method I want to expire all offers but, to do so, I have catch two specific errors (validations and possible AASM) and rescue from them. Both of them should be sended to Rollbar.
def call
all_to_expire.each do |offer|
offer.expire!(actor: self)
rescue StandardError => e
Rollbar.error(e)
end
end
Method above doesn't seem to work
I am not sure if Ruby is understanding this kind of block structure. I would rewrite it as:
def call
all_to_expire.each do |offer|
begin
offer.expire!(actor: self)
rescue AASM::InvalidTransition, ActiveModel::ValidationError => e
Rollbar.error(e)
end
end
end