Skip to content

Commit

Permalink
catch errors in downloadSong()
Browse files Browse the repository at this point in the history
  • Loading branch information
Araxeus committed Mar 15, 2023
1 parent b652a01 commit 51871a3
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion plugins/downloader/back.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const sendError = (error) => {
buttons: ["OK"],
title: "Error in download!",
message: "Argh! Apologies, download failed…",
detail: error.toString(),
detail: `${error.toString()} ${error.cause ? `\n\n${error.cause.toString()}` : ''}`,
});
};

Expand Down Expand Up @@ -89,6 +89,19 @@ async function downloadSong(
playlistFolder = undefined,
trackId = undefined,
increasePlaylistProgress = () => {},
) {
try {
await downloadSongUnsafe(url, playlistFolder, trackId, increasePlaylistProgress);
} catch (error) {
sendError(error);
}
}

async function downloadSongUnsafe(
url,
playlistFolder = undefined,
trackId = undefined,
increasePlaylistProgress = () => {},
) {
const sendFeedback = (message, progress) => {
if (!playlistFolder) {
Expand Down

0 comments on commit 51871a3

Please sign in to comment.