From 666cc3daf2358559b1ae8f2fe6c0e5bee2a74225 Mon Sep 17 00:00:00 2001 From: Taka Date: Sun, 30 Dec 2018 03:19:37 +0000 Subject: [PATCH] Tweaked how we handle errors during startup. --- vasl_templates/main.py | 11 +++++------ vasl_templates/server_settings.py | 3 +++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/vasl_templates/main.py b/vasl_templates/main.py index 843feab..a964897 100755 --- a/vasl_templates/main.py +++ b/vasl_templates/main.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 install_server_settings( True ) 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 - MainWindow.showErrorMsg( - "Couldn't install the server settings:\n {}\n\n" - "Please correct them in the \"Server settings\" dialog, or in the config file:\n {}".format( - ex, app_settings_fname - ) - ) + MainWindow.showErrorMsg( "Couldn't install the server settings:\n\n{}".format( ex ) ) + return 2 # disable the Flask "do not use in a production environment" warning import flask.cli diff --git a/vasl_templates/server_settings.py b/vasl_templates/server_settings.py index fb58b96..009e31b 100644 --- a/vasl_templates/server_settings.py +++ b/vasl_templates/server_settings.py @@ -1,6 +1,8 @@ """Implement the "server settings" dialog.""" import os +import logging +import traceback from PyQt5 import uic from PyQt5.QtWidgets import QDialog, QFileDialog, QGroupBox @@ -199,6 +201,7 @@ class ServerSettingsDialog( QDialog ): try: install_server_settings( False ) 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 ) ) return self.close()