Error handling search
This commit is contained in:
9
main.ts
9
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<void> {
|
||||
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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user