mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
catch errors in downloadSong()
This commit is contained in:
@ -59,7 +59,7 @@ const sendError = (error) => {
|
|||||||
buttons: ["OK"],
|
buttons: ["OK"],
|
||||||
title: "Error in download!",
|
title: "Error in download!",
|
||||||
message: "Argh! Apologies, download failed…",
|
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,
|
playlistFolder = undefined,
|
||||||
trackId = undefined,
|
trackId = undefined,
|
||||||
increasePlaylistProgress = () => {},
|
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) => {
|
const sendFeedback = (message, progress) => {
|
||||||
if (!playlistFolder) {
|
if (!playlistFolder) {
|
||||||
|
|||||||
Reference in New Issue
Block a user