Add a simple error catcher for most file loads.

This commit is contained in:
Tim Young 2017-07-31 16:23:38 -05:00
parent b7b5525413
commit 857c8750ba

View File

@ -1671,31 +1671,39 @@ namespace EduNetworkBuilder
}
//If it is a network file
string extension = Path.GetExtension(filename).ToLower();
//MessageBox.Show(filename + " " +extension);
if (extension == ".enbx")
//MessageBox.Show(filename + " " +extension);
try
{
PrepForLoad();
myNetwork.Load(filename);
UpdateMenu();
UpdateForm();
} else if(extension == ".enbu")
{
CurrentUser = new PersonClass(filename);
OurSettings = NB.GetSettings(); //Grab the new settings from the user
UpdateMenu();
if (extension == ".enbx")
{
PrepForLoad();
myNetwork.Load(filename);
UpdateMenu();
UpdateForm();
}
else if (extension == ".enbu")
{
CurrentUser = new PersonClass(filename);
OurSettings = NB.GetSettings(); //Grab the new settings from the user
UpdateMenu();
//Now, open a new window to edit them.
PersonProfileForm PPF = new PersonProfileForm(CurrentUser);
CurrentUser = PPF.Edit(); //This does the form as dialog. When we come back, update the menu.
UpdateMenu();
//Now, open a new window to edit them.
PersonProfileForm PPF = new PersonProfileForm(CurrentUser);
CurrentUser = PPF.Edit(); //This does the form as dialog. When we come back, update the menu.
UpdateMenu();
}
else
{
MessageBox.Show(NB.Translate("NB_InvalidFile"));
Close();
return; //We return here so we do not register the filename...
}
if (OurSettings != null) OurSettings.RegisterFileAsLoaded(filename);
}
else
catch (Exception e)
{
MessageBox.Show(NB.Translate("NB_InvalidFile"));
Close();
return; //We return here so we do not register the filename...
MessageBox.Show("Error: " + e.ToString());
}
if (OurSettings != null) OurSettings.RegisterFileAsLoaded(filename);
}
private void loadRecentFilename(object sender, EventArgs e)