refactor: Use early return

Signed-off-by: Tim Hårek Andreassen <tim@harek.no>
This commit is contained in:
Tim Hårek Andreassen 2024-04-08 17:21:00 +02:00
parent 5c6a3eff4e
commit a40830cebb
No known key found for this signature in database
GPG Key ID: E59C7734F0E10EB5
2 changed files with 7 additions and 5 deletions

View File

@ -48,7 +48,8 @@ async function updateFetch(existingSeries: Series): Promise<UpdatedSeries | null
const updateSuccessful = await storage.write(updated); const updateSuccessful = await storage.write(updated);
if (!updateSuccessful) { if (!updateSuccessful) {
throw new Error(`Failed to update series ${existingSeries.id}`); console.log(`Failed to update series ${existingSeries.id}`);
return null;
} }
return updated; return updated;

View File

@ -146,11 +146,12 @@ async function getEpisodeWithDownloadLink(
playbackResponse = body; playbackResponse = body;
} }
if (playbackStatus === STATUS_CODE.OK && playbackResponse) { if (playbackStatus !== STATUS_CODE.OK && !playbackResponse) {
return { ...episode, url: playbackResponse.playable.assets[0].url }; throw new Error(
} else { `Error getting downloadLink for ${episode.episodeId}, serie: ${episode.originalTitle}. Status: ${playbackStatus}`,
throw `Error getting downloadLink for ${episode.episodeId}, serie: ${episode.originalTitle}. Status: ${playbackStatus}`; );
} }
return { ...episode, url: playbackResponse.playable.assets[0].url };
} }
export const nrkRadio = { export const nrkRadio = {