Skip to content

Commit

Permalink
Catch exceptions when trying to save the config file.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinematics committed Oct 31, 2015
1 parent 1374bdb commit dc523b8
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions NetTally/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows;

namespace NetTally
{
Expand Down Expand Up @@ -122,10 +123,18 @@ public static void Save(Tally tally, QuestCollectionWrapper questsWrapper)
if (config == null)
return;

QuestsSection questConfig = config.Sections[QuestsSection.DefinedName] as QuestsSection;
questConfig.Save(questsWrapper);
try
{
QuestsSection questConfig = config.Sections[QuestsSection.DefinedName] as QuestsSection;
questConfig.Save(questsWrapper);

config.Save(ConfigurationSaveMode.Minimal);
config.Save(ConfigurationSaveMode.Minimal);
}
catch (Exception e)
{
string file = ErrorLog.Log(e);
MessageBox.Show($"Log saved to:\n{file ?? "(unable to write log file)"}", "Error saving configuration file", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}

Expand Down

0 comments on commit dc523b8

Please sign in to comment.