Skip to content

Commit 51871a3

Browse files
committed
catch errors in downloadSong()
1 parent b652a01 commit 51871a3

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

plugins/downloader/back.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const sendError = (error) => {
5959
buttons: ["OK"],
6060
title: "Error in download!",
6161
message: "Argh! Apologies, download failed…",
62-
detail: error.toString(),
62+
detail: `${error.toString()} ${error.cause ? `\n\n${error.cause.toString()}` : ''}`,
6363
});
6464
};
6565

@@ -89,6 +89,19 @@ async function downloadSong(
8989
playlistFolder = undefined,
9090
trackId = undefined,
9191
increasePlaylistProgress = () => {},
92+
) {
93+
try {
94+
await downloadSongUnsafe(url, playlistFolder, trackId, increasePlaylistProgress);
95+
} catch (error) {
96+
sendError(error);
97+
}
98+
}
99+
100+
async function downloadSongUnsafe(
101+
url,
102+
playlistFolder = undefined,
103+
trackId = undefined,
104+
increasePlaylistProgress = () => {},
92105
) {
93106
const sendFeedback = (message, progress) => {
94107
if (!playlistFolder) {

0 commit comments

Comments
 (0)