Show error messages when exporting files fails

This commit is contained in:
Tyler Anderson 2016-12-13 12:15:05 -08:00
parent 6c4a2eeb7d
commit dae087f87f
2 changed files with 67 additions and 11 deletions

View file

@ -379,9 +379,18 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
},
(saveParams) =>
{
if (!string.IsNullOrWhiteSpace(saveParams.FileName))
try
{
File.WriteAllText(saveParams.FileName, JsonConvert.SerializeObject(printerSettings, Formatting.Indented));
if (!string.IsNullOrWhiteSpace(saveParams.FileName))
{
File.WriteAllText(saveParams.FileName, JsonConvert.SerializeObject(printerSettings, Formatting.Indented));
}
}
catch (Exception e)
{
UiThread.RunOnIdle (() => {
StyledMessageBox.ShowMessageBox(null, e.Message, "Couldn't save file".Localize());
});
}
});
}
@ -395,9 +404,18 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
},
(saveParams) =>
{
if (!string.IsNullOrWhiteSpace(saveParams.FileName))
try
{
GenerateConfigFile(saveParams.FileName, false);
if (!string.IsNullOrWhiteSpace(saveParams.FileName))
{
GenerateConfigFile(saveParams.FileName, false);
}
}
catch (Exception e)
{
UiThread.RunOnIdle (() => {
StyledMessageBox.ShowMessageBox(null, e.Message, "Couldn't save file".Localize());
});
}
});
}