Reputation: 8954
I have an exception that is produced at ~20 seperate places. It can be rescued easy and in the same way at every place but thats not dry and eaven a crapy work! I want to rescue this exception at a central position. How can I arrange this?
Its about the ActiveRecord::RecordNonUnique
exception by the way,...
Upvotes: 4
Views: 784
Reputation: 5001
What about this ?
def rescue_from_record_non_unique
yield
rescue ActiveRecord::RecordNonUnique
# your code
end
# ...
rescue_from_record_non_unique do
# do something
end
Upvotes: 7