Handle unique constraint errors.