add missing try catch wrappers
This commit is contained in:
parent
e65c0581fb
commit
58f886015a
|
@ -67,6 +67,7 @@ export default function ExportModal(props: Props) {
|
|||
// SIDE EFFECTS
|
||||
// ====================
|
||||
useEffect(() => {
|
||||
try {
|
||||
if (!isElectron()) {
|
||||
return;
|
||||
}
|
||||
|
@ -74,10 +75,15 @@ export default function ExportModal(props: Props) {
|
|||
|
||||
exportService.electronAPIs.registerStopExportListener(stopExport);
|
||||
exportService.electronAPIs.registerPauseExportListener(pauseExport);
|
||||
exportService.electronAPIs.registerResumeExportListener(resumeExport);
|
||||
exportService.electronAPIs.registerResumeExportListener(
|
||||
resumeExport
|
||||
);
|
||||
exportService.electronAPIs.registerRetryFailedExportListener(
|
||||
retryFailedExport
|
||||
);
|
||||
} catch (e) {
|
||||
logError(e, 'error while registering export listeners');
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -85,10 +91,13 @@ export default function ExportModal(props: Props) {
|
|||
return;
|
||||
}
|
||||
const main = async () => {
|
||||
try {
|
||||
const exportInfo = await exportService.getExportRecord();
|
||||
setExportStage(exportInfo?.stage ?? ExportStage.INIT);
|
||||
setLastExportTime(exportInfo?.lastAttemptTimestamp);
|
||||
setExportProgress(exportInfo?.progress ?? { current: 0, total: 0 });
|
||||
setExportProgress(
|
||||
exportInfo?.progress ?? { current: 0, total: 0 }
|
||||
);
|
||||
setExportStats({
|
||||
success: exportInfo?.exportedFiles?.length ?? 0,
|
||||
failed: exportInfo?.failedFiles?.length ?? 0,
|
||||
|
@ -96,6 +105,12 @@ export default function ExportModal(props: Props) {
|
|||
if (exportInfo?.stage === ExportStage.INPROGRESS) {
|
||||
resumeExport();
|
||||
}
|
||||
} catch (e) {
|
||||
logError(
|
||||
e,
|
||||
'error while updating exportModal on exportFolder change'
|
||||
);
|
||||
}
|
||||
};
|
||||
main();
|
||||
}, [exportFolder]);
|
||||
|
@ -185,6 +200,7 @@ export default function ExportModal(props: Props) {
|
|||
updateExportStage(ExportStage.INPROGRESS);
|
||||
await sleep(100);
|
||||
};
|
||||
|
||||
const postExportRun = async (exportResult?: { paused?: boolean }) => {
|
||||
if (!exportResult?.paused) {
|
||||
updateExportStage(ExportStage.FINISHED);
|
||||
|
@ -195,11 +211,13 @@ export default function ExportModal(props: Props) {
|
|||
};
|
||||
|
||||
const selectExportDirectory = async () => {
|
||||
try {
|
||||
const newFolder = await exportService.selectExportDirectory();
|
||||
if (newFolder) {
|
||||
updateExportFolder(newFolder);
|
||||
} else {
|
||||
throw Error(CustomError.REQUEST_CANCELLED);
|
||||
}
|
||||
} catch (e) {
|
||||
logError(e, 'selectExportDirectory failed');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue