From 51871a3fecd87bee6f44e862af565b17d091bff9 Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Wed, 15 Mar 2023 20:29:12 +0200 Subject: [PATCH] catch errors in `downloadSong()` --- plugins/downloader/back.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/downloader/back.js b/plugins/downloader/back.js index 94920e85..22b9666e 100644 --- a/plugins/downloader/back.js +++ b/plugins/downloader/back.js @@ -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()}` : ''}`, }); }; @@ -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) {