From 31eeff88903b87c9beab49c9ac73001cee04cb1a Mon Sep 17 00:00:00 2001 From: OmerSabic Date: Wed, 22 Oct 2025 13:52:11 +0200 Subject: [PATCH] Error handling search --- main.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.ts b/main.ts index 1057cd4..40ca380 100644 --- a/main.ts +++ b/main.ts @@ -227,7 +227,7 @@ class DownloadQueue { while (this.activeDownloads < this.maxConcurrency && this.queue.length > 0) { const { url, folder, filename } = this.queue.shift()!; this.activeDownloads++; - + this.processDownload(url, folder, filename).then(() => { this.activeDownloads--; this.processQueue(); @@ -238,7 +238,7 @@ class DownloadQueue { }); } } - + private async processDownload(url: string, folder: string, filename: string): Promise { await downloadSong(url, folder, filename); songCount++; @@ -261,6 +261,11 @@ for (const mentalState of mentalStates) { authorization: `Bearer ${AUTHTOKEN}` } }); + if (!response.ok) { + chalk.red("ERROR SEARCHING SONGS") + chalk.red(response.text()); + continue; + } const responseData = await response.json(); const data = formatAudioData(responseData.result);