code: public static BatchResult newErrorResult(String errMsg) {
          BatchResult result = new BatchResult();
          result.setStatus(Status.ERROR);
          result.setErrorMessage(errMsg);
          return result;
      }
docs: Create a new BatchResult with an ERROR status and the given error message.
  
  @param errMsg    Error message.
  @return          New BatchResult object with ERROR status and given error message.