Skip to content

Commit bfb2186

Browse files
committed
1.3.x Error handling in cmd mode
1 parent 6404a1a commit bfb2186

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

code/export-msaccess-sql.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,15 @@ def load_config(self, fpath='config.json', loadbyinit=False):
232232
self.tree.all_checked_update()
233233
if self.mode.get() == "cmd":
234234
logger.info(f"Configuration`s uploaded: {fpath}")
235+
return True
235236
else:
236237
raise
237238
except:
238239
if loadbyinit:
239240
return
240241
if self.mode.get() == "cmd":
241242
logger.error(f"Configuration upload fail: {self.config_path.get()}")
242-
return
243+
return False
243244
fpath = filedialog.askopenfilename(filetypes=[("JSON files", "*.json")])
244245
if fpath:
245246
self.load_config(fpath)
@@ -314,8 +315,12 @@ def check_permissions(self):
314315
recordset = self.db.OpenRecordset("SELECT TOP 1 * FROM MSysRelationships")
315316
recordset.Close()
316317
return True
317-
except:
318-
self.show_permission_warning()
318+
except Exception as e:
319+
if self.mode.get() == "cmd":
320+
logger.error(f"Permissions test failed: {e}")
321+
raise
322+
else:
323+
self.show_permission_warning()
319324
return False
320325

321326
def get_referenced_tables(self, table_name):
@@ -478,8 +483,8 @@ def main():
478483
conf = args.config
479484
root.withdraw()
480485
app = GetWidgetsFrame(master=root, mode="cmd")
481-
app.load_config(conf)
482-
app.export()
486+
if app.load_config(conf):
487+
app.export()
483488
app.btn_exit()
484489
else:
485490
app = GetWidgetsFrame(master=root, padding=(2, 2))

0 commit comments

Comments
 (0)