From 857c8750bafbee38f79339ee248da464db09b287 Mon Sep 17 00:00:00 2001 From: Tim Young Date: Mon, 31 Jul 2017 16:23:38 -0500 Subject: [PATCH] Add a simple error catcher for most file loads. --- EduNetworkBuilder/NetworkBuilder.cs | 48 +++++++++++++++++------------ 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/EduNetworkBuilder/NetworkBuilder.cs b/EduNetworkBuilder/NetworkBuilder.cs index 009d01f..076ab45 100644 --- a/EduNetworkBuilder/NetworkBuilder.cs +++ b/EduNetworkBuilder/NetworkBuilder.cs @@ -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)