/**
* Wraps existing URL list logic with verbose logging for temporary debugging.
*
* @param {Array<string>} urls An array of URLs to process.
* @param {function(string): Promise<any>} processUrl A function to process each URL.
* @returns {Promise<Array<any>>} A promise that resolves with the results of processing the URLs.
*/
async function processUrlsWithLogging(urls, processUrl) {
console.debug("Starting URL processing...");
const results = [];
for (let i = 0; i < urls.length; i++) {
const url = urls[i];
console.debug(`Processing URL ${url} at index ${i}`);
try {
const result = await processUrl(url);
console.debug(`URL ${url} processed successfully. Result:`, result);
results.push(result);
} catch (error) {
console.error(`Error processing URL ${url}:`, error);
// Optionally, handle the error (e.g., retry, skip, etc.)
results.push(error); //Push error to results for tracking
}
}
console.debug("URL processing complete.");
return results;
}
Add your comment