Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/29/08 18:05:50 (17 years ago)
Author:
gkronber
Message:

fixed #160

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.StructureIdentification/StructIdProblemInjectorView.cs

    r172 r273  
    7474        bool success = false;
    7575        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);
    8287        }
    8388        if (success) {
     
    95100      }
    96101    }
     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    }
    97119  }
    98120}
Note: See TracChangeset for help on using the changeset viewer.