I have a table with a unique key (date + userid) in my webapp database. When i try to insert record with existing date and userid, i'm getting error "dupicate key in table". I turn on database debug in application config, because i need use mysql error number and message. And now i need processing this error. I can use hard coded constants in this controller, but i think it's not good idea - i need database error handling in many places and i dont like standate CI error handling.
How are you processing database errors? What is the best-practice?