use reject instead of throw

This commit is contained in:
Erik 2024-03-28 10:10:05 +02:00
parent b0354bd09e
commit 6efdbd88ea

View File

@ -132,13 +132,13 @@ class SpotifyDownloader extends Downloader
this.logger.debug('Got ID mismatch, attempting to parse stdout to find filename'); this.logger.debug('Got ID mismatch, attempting to parse stdout to find filename');
const match = stdout.match(reg); const match = stdout.match(reg);
if (!match) if (!match)
throw new Error('Got bad output from zotify (could not find file name) and could not find by ID from cache file'); return reject(new Error('Got bad output from zotify (could not find file name) and could not find by ID from cache file'));
const { file, name } = match.groups!; const { file, name } = match.groups!;
fs.appendFileSync(path.join(this.downloadDir!, '.song_ids'), `${id}\t${(new Date()).toLocaleString('sv')}\t${name}\t${file}`); fs.appendFileSync(path.join(this.downloadDir!, '.song_ids'), `${id}\t${(new Date()).toLocaleString('sv')}\t${name}\t${file}`);
data = this.#parseFilename(file); data = this.#parseFilename(file);
} }
if (!data) if (!data)
throw new Error('Failed to find file reference'); return reject(new Error('Failed to find file reference'));
const { fileName, artist, song, album, ext } = data; const { fileName, artist, song, album, ext } = data;
const filePath = path.join(this.downloadDir!, fileName); const filePath = path.join(this.downloadDir!, fileName);