private void processLogs(int exitCode, String outputFile, String errorFile) throws StackAdvisorException {
    printMessage("stdout", outputFile);
    String errMessage = printMessage("stderr", errorFile);

    try {
      if (exitCode != 0) {
        String errorMessage;
        if (errMessage != null) {
          // We want to get the last line.
          int index = errMessage.lastIndexOf("\n");
          if (index > 0 && index == (errMessage.length() - 1)) {
            index = errMessage.lastIndexOf("\n", index - 1); // sentence ended with newline
          }
          if (index > -1) {
            errMessage = errMessage.substring(index + 1).trim();
          }
          errorMessage = String.format("Stack Advisor reported an error. Exit Code: %s. Error: %s ", exitCode, errMessage);
        } else {
          errorMessage = String.format("Error occurred during Stack Advisor execution. Exit Code: %s", exitCode);
        }
        errorMessage += "\nStdOut file: " + outputFile + "\n";
        errorMessage += "\nStdErr file: " + errorFile;
        switch (exitCode) {
          case 1:
            throw new StackAdvisorRequestException(errorMessage);
          case 2:
            throw new StackAdvisorException(errorMessage);
        }
      }
    } catch (StackAdvisorException ex) {
      throw ex;
    }
  }
Process the exit code and logs. If non-zero then parse the log files and raise the appropriate exception.
@param exitCode Process exit code
@param outputFile Path to output file
@param errorFile Path to error file
@throws StackAdvisorException
ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorRunner.java