From 9585edf8129d1af3bce5fcbfa9b823076d456a14 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch> Date: Tue, 19 Dec 2017 16:45:36 +0100 Subject: [PATCH] Split loading of config and status into separate methods. --- AutoTx/AutoTx.cs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/AutoTx/AutoTx.cs b/AutoTx/AutoTx.cs index b4deb6d..b6b0da6 100644 --- a/AutoTx/AutoTx.cs +++ b/AutoTx/AutoTx.cs @@ -92,7 +92,7 @@ namespace AutoTx } /// <summary> - /// Loads the initial settings. + /// Load the initial settings. /// </summary> private void LoadSettings() { try { @@ -102,7 +102,8 @@ namespace AutoTx _configPath = Path.Combine(baseDir, "configuration.xml"); _statusPath = Path.Combine(baseDir, "status.xml"); - LoadConfigStatusXml(); + LoadConfigXml(); + LoadStatusXml(); _roboCommand = new RoboCommand(); } @@ -116,10 +117,11 @@ namespace AutoTx CheckConfiguration(); } + /// <summary> - /// Loads the configuration and status xml files. + /// Load the configuration xml file. /// </summary> - private void LoadConfigStatusXml() { + private void LoadConfigXml() { try { _config = ServiceConfig.Deserialize(_configPath); writeLogDebug("Loaded config from " + _configPath); @@ -129,17 +131,27 @@ namespace AutoTx // this should terminate the service process: throw new Exception("Error loading config."); } + } + + + /// <summary> + /// Load the status xml file. + /// </summary> + private void LoadStatusXml() { try { + writeLogDebug("Trying to load status from " + _statusPath); _status = ServiceStatus.Deserialize(_statusPath); writeLogDebug("Loaded status from " + _statusPath); } catch (Exception ex) { - writeLog("Error loading status XML: " + ex.Message, true); + writeLog("Error loading status XML from [" + _statusPath + "]: " + + ex.Message + "\n" + ex.StackTrace, true); // this should terminate the service process: throw new Exception("Error loading status."); } } + /// <summary> /// Check if loaded configuration is valid, print a summary to the log. /// </summary> -- GitLab