refactor: Use early return
Signed-off-by: Tim Hårek Andreassen <tim@harek.no>
This commit is contained in:
parent
5c6a3eff4e
commit
a40830cebb
|
|
@ -48,7 +48,8 @@ async function updateFetch(existingSeries: Series): Promise<UpdatedSeries | null
|
|||
|
||||
const updateSuccessful = await storage.write(updated);
|
||||
if (!updateSuccessful) {
|
||||
throw new Error(`Failed to update series ${existingSeries.id}`);
|
||||
console.log(`Failed to update series ${existingSeries.id}`);
|
||||
return null;
|
||||
}
|
||||
|
||||
return updated;
|
||||
|
|
|
|||
|
|
@ -146,11 +146,12 @@ async function getEpisodeWithDownloadLink(
|
|||
playbackResponse = body;
|
||||
}
|
||||
|
||||
if (playbackStatus === STATUS_CODE.OK && playbackResponse) {
|
||||
return { ...episode, url: playbackResponse.playable.assets[0].url };
|
||||
} else {
|
||||
throw `Error getting downloadLink for ${episode.episodeId}, serie: ${episode.originalTitle}. Status: ${playbackStatus}`;
|
||||
if (playbackStatus !== STATUS_CODE.OK && !playbackResponse) {
|
||||
throw new Error(
|
||||
`Error getting downloadLink for ${episode.episodeId}, serie: ${episode.originalTitle}. Status: ${playbackStatus}`,
|
||||
);
|
||||
}
|
||||
return { ...episode, url: playbackResponse.playable.assets[0].url };
|
||||
}
|
||||
|
||||
export const nrkRadio = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue