Handling MongoDB connection error gracefully