From 54348ca881d098c98fba4f65441c71a7aeb0b2a1 Mon Sep 17 00:00:00 2001 From: SGCMarkus Date: Mon, 4 Mar 2024 11:57:13 +0100 Subject: [PATCH] astrodatagui: improve error handling and connect to default db on start --- astrodatagui/AstrodataGUI.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/astrodatagui/AstrodataGUI.py b/astrodatagui/AstrodataGUI.py index c8de854..a490d34 100644 --- a/astrodatagui/AstrodataGUI.py +++ b/astrodatagui/AstrodataGUI.py @@ -3,7 +3,7 @@ import os from .db.StarsDB import StarDB -DB_FILENAME = "stars.db" +DEFAULT_DB = "stars.db" class AstrodataGUI(QtWidgets.QMainWindow): def __init__(self): @@ -17,10 +17,12 @@ class AstrodataGUI(QtWidgets.QMainWindow): def loadDB(self): try: - self.starDB = StarDB.getInstance() - except: + self.starDB = StarDB.getInstance(DEFAULT_DB) + except Exception as e: self.showErrorMessage("DB Connection failed", - f"Could not connect to local database file {DB_FILENAME}") + f"Could not connect to local database file {DEFAULT_DB}\n\ + {e}") def showErrorMessage(self, title: str, msg: str): - return \ No newline at end of file + print(title) + print(msg) \ No newline at end of file