astrodatagui: improve error handling and connect to default db on start

This commit is contained in:
2024-03-04 11:57:13 +01:00
parent 0648f36926
commit 54348ca881
+7 -5
View File
@@ -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
print(title)
print(msg)