Added error checking during index creation, to see whether MongoDB connection works.