# Specific exceptions for database errors: please speak up

**URL:** <https://www.ruby-forum.com/t/specific-exceptions-for-database-errors-please-speak-up/169262>\
**Category:** Rails\
**Created:** [June 1, 2009, 5:20pm UTC](https://www.ruby-forum.com/t/specific-exceptions-for-database-errors-please-speak-up/169262 "2009-06-01T17:20:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [June 1, 2009, 5:20pm UTC](https://www.ruby-forum.com/t/specific-exceptions-for-database-errors-please-speak-up/169262/1 "2009-06-01T17:20:58Z")

</div>

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-](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

–  
Michael S.  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://www.schuerig.de/michael/](http://www.schuerig.de/michael/)
