From 01128639ceddf62cb22d1fe3efd709de6fe5ccd9 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Thu, 4 Apr 2019 13:05:40 -0400 Subject: [PATCH] improve error logging --- src/client/spark/App.xaml.cs | 36 +++++++++++-------- .../spark/view/Shell/Login/LoginModel.cs | 2 +- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/client/spark/App.xaml.cs b/src/client/spark/App.xaml.cs index 07eff0bb0..25aecff08 100644 --- a/src/client/spark/App.xaml.cs +++ b/src/client/spark/App.xaml.cs @@ -79,28 +79,36 @@ namespace mbts.ui.shell static internal string stunnel_job_error { get; private set;} void init_stunnel(string[] argv) { - var path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\BTS\\stunnel\\"; - if(File.Exists(path + "config\\stunnel.conf")) + try { - try + var path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\BTS\\stunnel\\"; + if (File.Exists(path + "config\\stunnel.conf")) { - uint job_error = BTSUINativeMethods.setup_process_job_object(); - if(job_error != 0) - stunnel_job_error = "Stunnel Job Error code: " + job_error; - _stunnel_process = Process.Start(path + "bin\\stunnel.exe"); - string config_error; bool success = false; - if(_stunnel_process != null) + uint job_error = BTSUINativeMethods.setup_process_job_object(); + if(job_error == 0) { - for(int i = 0; i < 10; i++) + _stunnel_process = Process.Start(path + "bin\\stunnel.exe"); + string config_error; bool success = false; + if(_stunnel_process != null) { - if(success = mbts.config.Configuration.try_initialize(out config_error)) - break; - System.Threading.Thread.Sleep(500); + for(int i = 0; i < 10; i++) + { + if(success = mbts.config.Configuration.try_initialize(out config_error)) + break; + System.Threading.Thread.Sleep(500); + } } + else + stunnel_job_error = "Stunnel Job Error code: " + job_error + " could not start stunnel"; } + else + stunnel_job_error = "Stunnel Job Error code: " + job_error; } - catch {} //can't log here } + catch(Exception ex) + { + stunnel_job_error = "Error starting stunnel: " + ex.Message; + } } public new int Run() { diff --git a/src/client/spark/view/Shell/Login/LoginModel.cs b/src/client/spark/view/Shell/Login/LoginModel.cs index db5967be9..c3a42f7fb 100644 --- a/src/client/spark/view/Shell/Login/LoginModel.cs +++ b/src/client/spark/view/Shell/Login/LoginModel.cs @@ -94,7 +94,7 @@ namespace mbts.ui.shell { Configuration.initialize(); } catch (ApplicationException e) { - ErrorMessage = (e.Message ?? string.Empty) + (App.stunnel_job_error ?? string.Empty); + ErrorMessage = (e.Message ?? string.Empty) + " " + (App.stunnel_job_error ?? string.Empty); HasFatalError = true; return; }