1. /**
  2. * Wraps existing URL list logic with verbose logging for temporary debugging.
  3. *
  4. * @param {Array<string>} urls An array of URLs to process.
  5. * @param {function(string): Promise<any>} processUrl A function to process each URL.
  6. * @returns {Promise<Array<any>>} A promise that resolves with the results of processing the URLs.
  7. */
  8. async function processUrlsWithLogging(urls, processUrl) {
  9. console.debug("Starting URL processing...");
  10. const results = [];
  11. for (let i = 0; i < urls.length; i++) {
  12. const url = urls[i];
  13. console.debug(`Processing URL ${url} at index ${i}`);
  14. try {
  15. const result = await processUrl(url);
  16. console.debug(`URL ${url} processed successfully. Result:`, result);
  17. results.push(result);
  18. } catch (error) {
  19. console.error(`Error processing URL ${url}:`, error);
  20. // Optionally, handle the error (e.g., retry, skip, etc.)
  21. results.push(error); //Push error to results for tracking
  22. }
  23. }
  24. console.debug("URL processing complete.");
  25. return results;
  26. }

Add your comment