Tweaked how we handle errors during startup.

master
Pacman Ghost 5 years ago
parent fcf750b199
commit 666cc3daf2
  1. 11
      vasl_templates/main.py
  2. 3
      vasl_templates/server_settings.py

@ -116,13 +116,12 @@ def _do_main( template_pack, default_scenario, remote_debugging, debug ): #pylin
from vasl_templates.server_settings import install_server_settings #pylint: disable=cyclic-import from vasl_templates.server_settings import install_server_settings #pylint: disable=cyclic-import
install_server_settings( True ) install_server_settings( True )
except Exception as ex: #pylint: disable=broad-except except Exception as ex: #pylint: disable=broad-except
# NOTE: We used to advise the user to check the app config file for errors, but exceptions can be thrown
# for reasons other than errors in that file (e.g. bad JSON in the vehicle/ordnance data files).
logging.critical( traceback.format_exc() )
from vasl_templates.main_window import MainWindow #pylint: disable=cyclic-import from vasl_templates.main_window import MainWindow #pylint: disable=cyclic-import
MainWindow.showErrorMsg( MainWindow.showErrorMsg( "Couldn't install the server settings:\n\n{}".format( ex ) )
"Couldn't install the server settings:\n {}\n\n" return 2
"Please correct them in the \"Server settings\" dialog, or in the config file:\n {}".format(
ex, app_settings_fname
)
)
# disable the Flask "do not use in a production environment" warning # disable the Flask "do not use in a production environment" warning
import flask.cli import flask.cli

@ -1,6 +1,8 @@
"""Implement the "server settings" dialog.""" """Implement the "server settings" dialog."""
import os import os
import logging
import traceback
from PyQt5 import uic from PyQt5 import uic
from PyQt5.QtWidgets import QDialog, QFileDialog, QGroupBox from PyQt5.QtWidgets import QDialog, QFileDialog, QGroupBox
@ -199,6 +201,7 @@ class ServerSettingsDialog( QDialog ):
try: try:
install_server_settings( False ) install_server_settings( False )
except Exception as ex: #pylint: disable=broad-except except Exception as ex: #pylint: disable=broad-except
logging.error( traceback.format_exc() )
MainWindow.showErrorMsg( "Couldn't install the server settings:\n\n{}".format( ex ) ) MainWindow.showErrorMsg( "Couldn't install the server settings:\n\n{}".format( ex ) )
return return
self.close() self.close()

Loading…
Cancel
Save