better exception handling for unique constraint violations.