From 5cf79a61205743f336a3d361ca4fa63557a9ce6b Mon Sep 17 00:00:00 2001 From: Jaben Cargman Date: Tue, 5 Dec 2017 21:51:12 -0500 Subject: [PATCH] Added a check for the MessagePath configuration loader which will now soft fail if it cannot load the configuration. --- .../SettingPathTemplateProvider.cs | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/Papercut.UI/SettingPathTemplateProvider.cs b/src/Papercut.UI/SettingPathTemplateProvider.cs index 6af8af95..b64e62ac 100644 --- a/src/Papercut.UI/SettingPathTemplateProvider.cs +++ b/src/Papercut.UI/SettingPathTemplateProvider.cs @@ -40,15 +40,32 @@ public SettingPathTemplateProvider(ILogger logger) PathTemplates = new ObservableCollection(MessagePaths); } - IEnumerable MessagePaths + private IEnumerable MessagePaths { get { - return - Settings.Default.MessagePaths.Split(new[] { ';', ',' }) - .Select(s => s.Trim()) - .Where(s => !string.IsNullOrWhiteSpace(s)) - .Distinct(); + + return GetMessagePath() + .Split(new[] { ';', ',' }) + .Select(s => s.Trim()) + .Where(s => !string.IsNullOrWhiteSpace(s)) + .Distinct(); + } + } + + private string GetMessagePath() + { + try + { + return Settings.Default.MessagePaths; + } + catch (System.Exception ex) + { + // message path loading is failing + this._logger.Error(ex, "Failed to load message paths"); + + // use default + return "%ApplicationData%\\Papercut;%BaseDirectory%;%BaseDirectory%\\Incoming"; } }