fix sendError()

This commit is contained in:
Araxeus
2021-05-08 19:34:57 +03:00
parent b3da77a6bc
commit e46e7b74e2
2 changed files with 5 additions and 4 deletions

View File

@ -10,7 +10,7 @@ const { cropMaxWidth } = require("./utils");
const { ACTIONS, CHANNEL } = require("./actions.js");
const { getImage } = require("../../providers/song-info");
const sendError = (err) => {
const sendError = (win, err) => {
const dialogOpts = {
type: "info",
buttons: ["OK"],
@ -34,7 +34,7 @@ function handle(win) {
listenAction(CHANNEL, (event, action, arg) => {
switch (action) {
case ACTIONS.ERROR: //arg = error
sendError(arg);
sendError(win, arg);
break;
case ACTIONS.METADATA:
event.returnValue = JSON.stringify(metadata);
@ -77,7 +77,7 @@ function handle(win) {
writer.addTag();
fileBuffer = Buffer.from(writer.arrayBuffer);
} catch (error) {
sendError(error);
sendError(win, error);
}
writeFileSync(filePath, fileBuffer);

View File

@ -32,7 +32,7 @@ module.exports = (win, options) => {
const currentURL = metadataURL || win.webContents.getURL();
const playlistID = new URL(currentURL).searchParams.get("list");
if (!playlistID) {
sendError(new Error("No playlist ID found"));
sendError(win, new Error("No playlist ID found"));
return;
}
@ -46,6 +46,7 @@ module.exports = (win, options) => {
const playlistFolder = join(folder, playlistTitle);
if (existsSync(playlistFolder)) {
sendError(
win,
new Error(`The folder ${playlistFolder} already exists`)
);
return;