Improve guards for theme loading

This commit is contained in:
John Lewin 2018-10-22 12:22:18 -07:00
parent 367c3b67eb
commit 819d7ef453
2 changed files with 13 additions and 3 deletions

View file

@ -79,8 +79,18 @@ namespace MatterHackers.MatterControl
public ThemeSet GetTheme(string themeName, Color accentColor)
{
var themeset = JsonConvert.DeserializeObject<ThemeSet>(
AggContext.StaticData.ReadAllText(Path.Combine(path, themeName + ".json")));
ThemeSet themeset = null;
try
{
themeset = JsonConvert.DeserializeObject<ThemeSet>(
AggContext.StaticData.ReadAllText(Path.Combine(path, themeName + ".json")));
}
catch
{
themeset = JsonConvert.DeserializeObject<ThemeSet>(
AggContext.StaticData.ReadAllText(Path.Combine(path, this.ThemeNames.First() + ".json")));
}
themeset.ThemeID = themeName;
themeset.SetAccentColor(accentColor);