Changeset 273 for trunk/sources/HeuristicLab.StructureIdentification
- Timestamp:
- 05/29/08 18:05:50 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.StructureIdentification/StructIdProblemInjectorView.cs
r172 r273 74 74 bool success = false; 75 75 try { 76 parser.Import(openFileDialog.FileName, true); 77 success = true; 78 } catch (Exception) { 79 // not possible to parse strictly => try to parse non-strict 80 parser.Import(openFileDialog.FileName, false); 81 success = true; 76 try { 77 parser.Import(openFileDialog.FileName, true); 78 success = true; 79 } catch(DataFormatException) { 80 // not possible to parse strictly => try to parse non-strict 81 parser.Import(openFileDialog.FileName, false); 82 success = true; 83 } 84 } catch(DataFormatException ex) { 85 // if the non-strict parsing also failed then show the exception 86 ShowErrorMessageBox(ex); 82 87 } 83 88 if (success) { … … 95 100 } 96 101 } 102 103 private void ShowErrorMessageBox(Exception ex) { 104 MessageBox.Show(BuildErrorMessage(ex), 105 "Error - " + ex.GetType().Name, 106 MessageBoxButtons.OK, 107 MessageBoxIcon.Error); 108 } 109 private string BuildErrorMessage(Exception ex) { 110 StringBuilder sb = new StringBuilder(); 111 sb.Append("Sorry, but something went wrong!\n\n" + ex.Message + "\n\n" + ex.StackTrace); 112 113 while(ex.InnerException != null) { 114 ex = ex.InnerException; 115 sb.Append("\n\n-----\n\n" + ex.Message + "\n\n" + ex.StackTrace); 116 } 117 return sb.ToString(); 118 } 97 119 } 98 120 }
Note: See TracChangeset
for help on using the changeset viewer.