How to save the exception of central and dry?

I have an exception that is thrown in ~ 20 separate places. It can be saved easily and in exactly the same way as in any place, but it does not dry out and does not suit the work of therapy! I want to save this exception in a central position. How can I arrange this?

Its about the exception of ActiveRecord::RecordNonUnique , by the way ...

+4
source share
1 answer

How about this?

 def rescue_from_record_non_unique yield rescue ActiveRecord::RecordNonUnique # your code end # ... rescue_from_record_non_unique do # do something end 
+6
source

Source: https://habr.com/ru/post/1388123/


All Articles