Handle MongoDB error