public QTestProcessExecResult checkNegativeResults(String tname, Error e) throws Exception {

    String outFileExtension = getOutFileExtension();

    File qf = new File(outDir, tname);
    String expf = outPath(outDir.toString(), tname.concat(outFileExtension));

    File outf = null;
    outf = new File(logDir);
    outf = new File(outf, qf.getName().concat(outFileExtension));

    FileWriter outfd = new FileWriter(outf, true);

    outfd.write("FAILED: "
        + e.getClass().getSimpleName()
        + " "
        + e.getClass().getName()
        + ": "
        + e.getMessage()
        + "\n");
    outfd.close();

    QTestProcessExecResult result = qTestResultProcessor.executeDiffCommand(outf.getPath(), expf, false);
    if (QTestSystemProperties.shouldOverwriteResults()) {
      qTestResultProcessor.overwriteResults(outf.getPath(), expf);
      return QTestProcessExecResult.createWithoutOutput(0);
    }

    return result;
  }
This allows a .q file to continue executing after a statement runs into an error which is convenient
if you want to use another hive cmd after the failure to sanity check the state of the system.
itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java