Skip to content

Commit

Permalink
Added a check for the MessagePath configuration loader which will now…
Browse files Browse the repository at this point in the history
… soft fail if it cannot load the configuration.
  • Loading branch information
Jaben Cargman committed Dec 6, 2017
1 parent 595e69c commit 5cf79a6
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/Papercut.UI/SettingPathTemplateProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,32 @@ public SettingPathTemplateProvider(ILogger logger)
PathTemplates = new ObservableCollection<string>(MessagePaths);
}

IEnumerable<string> MessagePaths
private IEnumerable<string> 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";
}
}

Expand Down

0 comments on commit 5cf79a6

Please sign in to comment.