Add try catch for addDocuments function