r/SQL • u/ModerateSentience • Apr 23 '26
PostgreSQL Handling exceptions question
So if I have a website and let’s say, for instance, that a user can sign up and there might be multiple constraints to actually put something into the database such as a unique tag or whatever else. If I just catch integrity errors from the sql database in my back end I won’t know exactly what caused the integrity error. So how do people actually handle these exceptions to display something meaningful to the User? Does this involve retroactively checking why the insertion failed or actually somehow parsing the exception in your back end?
View all comments
Show parent comment
1
u/ModerateSentience Apr 23 '26
Is it not gonna be expensive for my database to search for these things before to see if it’s unique