Replace exception handling for control flow

This commit is contained in:
Manav Rathi 2024-04-14 19:39:35 +05:30
parent cc323905d5
commit 4d19c46d7c
No known key found for this signature in database

View file

@ -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<void> => {
@ -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);
}
};