astrodatagui: improve error handling and connect to default db on start
This commit is contained in:
@@ -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)
|
||||
Reference in New Issue
Block a user