Skip to content

Commit

Permalink
More error checking
Browse files Browse the repository at this point in the history
  • Loading branch information
willie-yao committed Feb 11, 2023
1 parent a4e0e32 commit 46e5b68
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ ipcMain.handle('open-google-login', async (event, arg) => {
});

ipcMain.handle('upload-videos', async (event, args) => {
fs.readdirSync(args.path).forEach((videoName: any) => {
return fs.readdirSync(args.path).forEach((videoName: any) => {
const fileSize = fs.statSync(args.path + videoName).size;
if (path.extname(videoName).toLowerCase() === '.mp4') {
console.log('videoName', videoName);
Expand Down Expand Up @@ -153,7 +153,8 @@ ipcMain.handle('upload-videos', async (event, args) => {
console.log('response', response);
})
.catch((error: any) => {
return error;
console.log('error', error);
return error.errors[0].message;
});
}
});
Expand Down
9 changes: 8 additions & 1 deletion src/renderer/pages/YTUploadView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,14 @@ const YTUploadView = () => {
playlistName: selectedFolder,
accessToken: accessToken,
};
window.electron.ipcRenderer.uploadVideos(params)
window.electron.ipcRenderer.uploadVideos(params).then((response) => {
console.log(response);
setSuccessMessage('Upload successful!');
setSuccessOpen(true);
}).catch((err) => {
setErrorMessage('Error uploading: ' + err);
setErrorOpen(true);
})
};

return (
Expand Down

0 comments on commit 46e5b68

Please sign in to comment.