Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/12/13 13:05:24 (11 years ago)
Author:
ascheibe
Message:

#2069

  • fixed error handling for external program calls
  • added missing StorableClass attribute
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Robocode/HeuristicLab.Problems.Robocode/Interpreter.cs

    r9601 r9612  
    7070      string cmdOutput = javaCompile.StandardOutput.ReadToEnd();
    7171      cmdOutput += javaCompile.StandardError.ReadToEnd();
     72
    7273      //Evaluator.tankStatLog += cmdOutput;
    7374      //Console.WriteLine(cmdOutput);
     
    7980
    8081      javaCompile.WaitForExit();
     82      if (javaCompile.ExitCode != 0) {
     83        return -1000.0;
     84      }
    8185      #endregion
    8286
     
    101105      evaluateCode.Start();
    102106
    103       // instead of p.WaitForExit(), do
    104107      StringBuilder q = new StringBuilder();
    105108      string scoreString = "";
    106       while (!evaluateCode.HasExited) {
     109      evaluateCode.WaitForExit();
     110
     111      try {
    107112        scoreString = evaluateCode.StandardOutput.ReadToEnd().Split(
    108113        new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).Last();
    109114        q.Append("Output: " + scoreString + "\r\n");
    110115        q.Append("Error: " + evaluateCode.StandardError.ReadToEnd() + "\r\n");
    111       }
    112       cmdOutput += q.ToString();
     116        cmdOutput += q.ToString();
     117      }catch {
     118        return -1000.0;
     119      }
    113120
    114121      #endregion
Note: See TracChangeset for help on using the changeset viewer.