With ActiveRecord as it currently is, you get the same error for anything that might go wrong in the database, ActiveRecord::InvalidStatement. That's rather undistinctive, considering that there are some problems only the database server can recognize, in particular violated uniqueness and foreign key constraints.
If specific exceptions for these tow latter error conditions would help you in your code, or if you are interested in the topic in general, please review the following ticket and patch
https://rails.lighthouseapp.com/projects/8994/tickets/2419-raise- specific-exceptions-for-violated-database-constraints
Please state your opinion and/or support, for otherwise the issue might be delayed interminably.
Thanks, Michael