fix: remove redundant try/catch since error is already handled with fetchCoverArt.catch()

This commit is contained in:
Pierre
2025-03-20 12:57:01 +01:00
committed by HiItsStolas
parent 5581865fc3
commit 81faf7d8ab

View File

@@ -186,32 +186,25 @@ class CoverArtArchive extends ExternalAPI {
}
if (idsToFetch.length > 0) {
try {
const batchPromises = idsToFetch.map((id) =>
this.fetchCoverArt(id)
.then((response) => {
const frontImage = response.images.find((img) => img.front);
resultsMap.set(id, frontImage?.thumbnails?.[250] || null);
return true;
})
.catch((error) => {
logger.error('Failed to fetch cover art', {
label: 'CoverArtArchive',
id,
error: error instanceof Error ? error.message : 'Unknown error',
});
resultsMap.set(id, null);
return false;
})
);
const batchPromises = idsToFetch.map((id) =>
this.fetchCoverArt(id)
.then((response) => {
const frontImage = response.images.find((img) => img.front);
resultsMap.set(id, frontImage?.thumbnails?.[250] || null);
return true;
})
.catch((error) => {
logger.error('Failed to fetch cover art', {
label: 'CoverArtArchive',
id,
error: error instanceof Error ? error.message : 'Unknown error',
});
resultsMap.set(id, null);
return false;
})
);
await Promise.allSettled(batchPromises);
} catch (error) {
logger.error('Failed to process cover art requests', {
label: 'CoverArtArchive',
error: error instanceof Error ? error.message : 'Unknown error',
});
}
await Promise.allSettled(batchPromises);
}
const results: Record<string, string | null> = {};