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);
|
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;
|
||||||
|
|
|
||||||
|
|
@ -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 = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue