public static void reportException(ErrorReporter er, RhinoException ex) {
   if (er instanceof ToolErrorReporter) {
     ((ToolErrorReporter) er).reportException(ex);
   } else {
     String msg = getExceptionMessage(ex);
     er.error(msg, ex.sourceName(), ex.lineNumber(), ex.lineSource(), ex.columnNumber());
   }
 }
 private void warn(String message, boolean showDebugString) {
   if (verbose) {
     if (showDebugString) {
       message = message + "\r\n" + getDebugString(10);
     }
     logger.warning(message, null, -1, null, -1);
   }
 }
Beispiel #3
0
  /**
   * Adds an audit error to the {@link KNSGlobalVariables.getAuditErrorMap()
   * KNSGlobalVariables.getAuditErrorMap()}.
   *
   * @param error the error to add.
   * @param errorKey the error map key
   * @param clusterLabel the cluster label
   * @param clusterCategory the cluster category
   * @throws IllegalArgumentException if error, errorKey, clusterLabel, or clusterCategory are null
   *     or if errorKey, clusterLabel, or clusterCategory are whitespace
   */
  public void reportAuditError(
      AuditError error, String errorKey, String clusterLabel, String clusterCategory) {
    if (error == null
        || StringUtils.isBlank(errorKey)
        || StringUtils.isBlank(clusterLabel)
        || StringUtils.isBlank(clusterCategory)) {
      throw new IllegalArgumentException(
          new StringBuilder("null argument error: ")
              .append(error)
              .append(" errorkey: ")
              .append(errorKey)
              .append(" clusterLabel: ")
              .append(clusterLabel)
              .append(" clusterCategory: ")
              .append(clusterCategory)
              .toString());
    }

    if (LOG.isDebugEnabled()) {
      LOG.debug("rule failure at " + ErrorReporter.getMethodPath(1, 2));
    }

    @SuppressWarnings("unchecked")
    final Map<String, AuditCluster> errorMap = KNSGlobalVariables.getAuditErrorMap();

    AuditCluster cluster = errorMap.get(errorKey);

    if (cluster == null) {
      cluster = new AuditCluster(clusterLabel, new ArrayList<AuditError>(), clusterCategory);
      errorMap.put(errorKey, cluster);
    }

    @SuppressWarnings("unchecked")
    final Collection<AuditError> errors = cluster.getAuditErrorList();
    errors.add(error);
  }
Beispiel #4
0
  /**
   * Runs the server. The server will wait for some match info (which specifies the teams and set of
   * maps to run) and then begin running matches.
   */
  public void run() {
    int aWins = 0, bWins = 0;

    while (!matches.isEmpty()) {
      Match match = matches.peek();
      if (!finished.isEmpty())
        match.setInitialTeamMemory(finished.getLast().getComputedTeamMemory());

      try {
        debug("running match " + match);
        match.initialize();
        runMatch(match, proxyWriter);
        finished.add(match);
        matches.remove(match);

        if (match.getWinner() == Team.A) aWins++;
        else if (match.getWinner() == Team.B) bWins++;

        match.finish();

        // Allow best of three scrimmages -- single game scrims should still work fine
        // TODO:This "win mode" should probably be something from the database
        if (mode == Mode.TOURNAMENT || mode == Mode.SCRIMMAGE) {
          if (aWins == 2 || bWins == 2) break;
        }

      } catch (Exception e) {
        ErrorReporter.report(e);
        error("couldn't run match: ");

        this.state = State.ERROR;
      }
    }

    proxyWriter.terminate();
  }
Beispiel #5
0
 /**
  * Wrapper around global errorMap.put call, to allow better logging.
  *
  * @param propertyName
  * @param errorKey
  * @param errorParams
  */
 public void reportError(String propertyName, String errorKey, String... errorParams) {
   GlobalVariables.getMessageMap().putError(propertyName, errorKey, errorParams);
   if (LOG.isDebugEnabled()) {
     LOG.debug("rule failure at " + ErrorReporter.getMethodPath(1, 2));
   }
 }
Beispiel #6
0
 /**
  * Wrapper around global errorMap.put call, to allow better logging.
  *
  * @param propertyName
  * @param errorKey
  * @param errorParams
  */
 public void reportWarning(String propertyName, String errorKey, String... errorParams) {
   GlobalVariables.getMessageMap().putWarning(propertyName, errorKey, errorParams);
   if (LOG.isDebugEnabled()) {
     LOG.debug(String.format("rule warning at ", ErrorReporter.getMethodPath(1, 2)));
   }
 }
Beispiel #7
0
 public void reportSoftError(String propertyName, String errorKey, String... errorParams) {
   addSoftError(propertyName, errorKey, errorParams);
   if (LOG.isDebugEnabled()) {
     LOG.debug("rule failure at " + ErrorReporter.getMethodPath(1, 2));
   }
 }