Applications should branch on SQLSTATE, not on the error text. Class 23 covers integrity violations: 23505 unique, 23503 foreign key, 23514 check.