When an exception comes from rails, it has a name, i.e:
“AssociationTypeMismatch”, so I can catch it like this:
rescue ActiveRecord::AssociationTypeMismatch => e ... ...
However, how can I catch and handle specific exceptions that come from
the database. “rescue Exception => e” is not good enough. I want to be
able to deal with them individually. for example, mysql throws a
duplicate entry key error, how do I catch that in rails?