Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/31/08 10:07:09 (16 years ago)
Author:
gkronber
Message:

fixed #218 (DistributedEngine silently ignores when grid-jobs are canceled (because of exceptions) on grid-clients) by adding a property that holds an error message to the ProcessingEngine

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Grid/ProcessingEngine.cs

    r412 r413  
    3636    }
    3737
     38    private string errorMessage;
     39    public string ErrorMessage {
     40      get { return errorMessage; }
     41    }
     42
    3843    public ProcessingEngine()
    3944      : base() {
     
    5156      canceledAttr.Value = Canceled.ToString();
    5257      node.Attributes.Append(canceledAttr);
     58      if(errorMessage != null) {
     59        XmlAttribute errorMessageAttr = document.CreateAttribute("ErrorMessage");
     60        errorMessageAttr.Value = ErrorMessage;
     61        node.Attributes.Append(errorMessageAttr);
     62      }
    5363      node.AppendChild(PersistenceManager.Persist("InitialOperation", initialOperation, document, persistedObjects));
    5464      return node;
     
    5868      base.Populate(node, restoredObjects);
    5969      myCanceled = bool.Parse(node.Attributes["Canceled"].Value);
     70      if(node.Attributes["ErrorMessage"] != null) errorMessage = node.Attributes["ErrorMessage"].Value;
    6071      initialOperation = (AtomicOperation)PersistenceManager.Restore(node.SelectSingleNode("InitialOperation"), restoredObjects);
    6172    }
     
    6980          next = atomicOperation.Operator.Execute(atomicOperation.Scope);
    7081        } catch(Exception ex) {
    71           Trace.TraceWarning("Exception while executing an engine.\n" + ex.Message + "\n" + ex.StackTrace);
     82          errorMessage = CreateErrorMessage(ex);
     83          Trace.TraceWarning(errorMessage);
    7284          // push operation on stack again
    7385          myExecutionStack.Push(atomicOperation);
     
    8395      }
    8496    }
     97
     98    private string CreateErrorMessage(Exception ex) {
     99      StringBuilder sb = new StringBuilder();
     100      sb.Append("Sorry, but something went wrong!\n\n" + ex.Message + "\n\n" + ex.StackTrace);
     101
     102      while(ex.InnerException != null) {
     103        ex = ex.InnerException;
     104        sb.Append("\n\n-----\n\n" + ex.Message + "\n\n" + ex.StackTrace);
     105      }
     106      return sb.ToString();
     107    }
    85108  }
    86109}
Note: See TracChangeset for help on using the changeset viewer.