Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/13/19 10:02:57 (5 years ago)
Author:
chaider
Message:

#2971 Added exception handling for constraint parser

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/IntervalConstraintsParser.cs

    r17146 r17250  
    4747          if (match.Success) {
    4848            if (match.Groups.Count != 10) {
    49               throw new ArgumentException("The target-constraint is not complete.");
     49              throw new ArgumentException("The target-constraint is not complete.", line);
    5050            } else {
    5151              var targetVariable = match.Groups[1].Value.Trim();
     
    5555
    5656              if (targetVariable != target) {
    57                 throw new ArgumentException($"The target variable {targetVariable}  does not match the provided target {target}.");
     57                throw new ArgumentException($"The target variable {targetVariable}  does not match the provided target {target}.", line);
    5858              }
    5959
     
    7474            }
    7575          } else {
    76             throw new ArgumentException("The inserted target constraint is not valid.");
     76            throw new ArgumentException("The inserted target constraint is not valid.", line);
    7777          }
    7878          //Check for derivation
     
    8383          if (match.Success) {
    8484            if (match.Groups.Count != 17) {
    85               throw new ArgumentException("The given derivation-constraint is not complete.");
     85              throw new ArgumentException("The given derivation-constraint is not complete.", line);
    8686            } else {
    8787              var derivationTarget = match.Groups[3].Value.Trim();
     
    9696
    9797              if (derivationTarget != target) {
    98                 throw new ArgumentException($"The target variable {derivationTarget}  does not match the provided target {target}.");
     98                throw new ArgumentException($"The target variable {derivationTarget}  does not match the provided target {target}.", line);
    9999              }
    100100
    101101              if (variables.All(v => v != derivationVariable)) {
    102                 throw new ArgumentException($"The given variable {derivationVariable} does not exist in the dataset.");
     102                throw new ArgumentException($"The given variable {derivationVariable} does not exist in the dataset.", line);
    103103              }
    104104
    105105              if (match.Groups[2].Value.Trim() != "" || match.Groups[11].Value.Trim() != "") {
    106106                if (match.Groups[2].Value.Trim() == "" || match.Groups[11].Value.Trim() == "")
    107                   throw new ArgumentException("Number of derivation has to be written on both sides.");
     107                  throw new ArgumentException("Number of derivation has to be written on both sides.", line);
    108108                if (match.Groups[2].Value.Trim() != match.Groups[11].Value.Trim())
    109                   throw new ArgumentException("Derivation number is not equal on both sides.");
     109                  throw new ArgumentException("Derivation number is not equal on both sides.", line);
    110110              }
    111111
     
    126126            }
    127127          } else {
    128             throw new ArgumentException("The inserted derivation constraint is not valid.");
     128            throw new ArgumentException("The inserted derivation constraint is not valid.", line);
    129129          }
    130130          //Check for comment
     
    133133          continue;
    134134        } else {
    135           throw new ArgumentException("Error at your constraints definition constraints have to start with (Target: | d | \u2202 | #)");
     135          throw new ArgumentException("Error at your constraints definition constraints have to start with (Target: | d | \u2202 | #)", line);
    136136        }
    137137      }
Note: See TracChangeset for help on using the changeset viewer.