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
|
from .db.StarsDB import StarDB
|
||||||
|
|
||||||
DB_FILENAME = "stars.db"
|
DEFAULT_DB = "stars.db"
|
||||||
|
|
||||||
class AstrodataGUI(QtWidgets.QMainWindow):
|
class AstrodataGUI(QtWidgets.QMainWindow):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -17,10 +17,12 @@ class AstrodataGUI(QtWidgets.QMainWindow):
|
|||||||
|
|
||||||
def loadDB(self):
|
def loadDB(self):
|
||||||
try:
|
try:
|
||||||
self.starDB = StarDB.getInstance()
|
self.starDB = StarDB.getInstance(DEFAULT_DB)
|
||||||
except:
|
except Exception as e:
|
||||||
self.showErrorMessage("DB Connection failed",
|
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):
|
def showErrorMessage(self, title: str, msg: str):
|
||||||
return
|
print(title)
|
||||||
|
print(msg)
|
||||||
Reference in New Issue
Block a user