Handle duplicate user error and database exception