From 4d19c46d7c1cb78a3f442594e941108c11de81e4 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Sun, 14 Apr 2024 19:39:35 +0530 Subject: [PATCH] Replace exception handling for control flow --- web/apps/photos/src/components/ExportModal.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/web/apps/photos/src/components/ExportModal.tsx b/web/apps/photos/src/components/ExportModal.tsx index 159c872e4..ca9a8c20f 100644 --- a/web/apps/photos/src/components/ExportModal.tsx +++ b/web/apps/photos/src/components/ExportModal.tsx @@ -101,8 +101,9 @@ export default function ExportModal(props: Props) { appContext.setDialogMessage( getExportDirectoryDoesNotExistMessage(), ); - throw Error(CustomError.EXPORT_FOLDER_DOES_NOT_EXIST); + return false; } + return true; }; const syncExportRecord = async (exportFolder: string): Promise => { @@ -144,8 +145,8 @@ export default function ExportModal(props: Props) { }; const toggleContinuousExport = async () => { + if (!(await verifyExportFolderExists())) return; try { - await verifyExportFolderExists(); const newContinuousExport = !continuousExport; if (newContinuousExport) { exportService.enableContinuousExport(); @@ -159,13 +160,11 @@ export default function ExportModal(props: Props) { }; const startExport = async () => { + if (!(await verifyExportFolderExists())) return; try { - await verifyExportFolderExists(); await exportService.scheduleExport(); } catch (e) { - if (e.message !== CustomError.EXPORT_FOLDER_DOES_NOT_EXIST) { - log.error("scheduleExport failed", e); - } + log.error("scheduleExport failed", e); } };