docs: static private void checkErrorAndThrowExceptionSub(
        JsonNode rootNode, boolean raiseReauthenticateError)
    throws SnowflakeSQLException
    {
      // no need to throw exception if success
      if (rootNode.path("success").asBoolean())
      {
        return;
      }
  
      String errorMessage;
      String sqlState;
      int errorCode;
      String queryId = "unknown";
  
      // if we have sqlstate in data, it's a sql error
      if (!rootNode.path("data").path("sqlState").isMissingNode())
      {
        sqlState = rootNode.path("data").path("sqlState").asText();
        errorCode = rootNode.path("data").path("errorCode").asInt();
        queryId = rootNode.path("data").path("queryId").asText();
        errorMessage = rootNode.path("message").asText();
      }
      else
      {
        sqlState = SqlState.INTERNAL_ERROR; // use internal error sql state
  
        // check if there is an error code in the envelope
        if (!rootNode.path("code").isMissingNode())
        {
          errorCode = rootNode.path("code").asInt();
          errorMessage = rootNode.path("message").asText();
        }
        else
        {
          errorCode = ErrorCode.INTERNAL_ERROR.getMessageCode();
          errorMessage = "no_error_code_from_server";
  
          try
          {
            PrintWriter writer = new PrintWriter("output.json", "UTF-8");
            writer.print(rootNode.toString());
          }
          catch (Exception ex)
          {
            logger.debug("{}", ex);
          }
        }
      }
  
      if (raiseReauthenticateError)
      {
        switch (errorCode)
        {
          case ID_TOKEN_EXPIRED_GS_CODE:
          case SESSION_NOT_EXIST_GS_CODE:
          case MASTER_TOKEN_NOTFOUND:
          case MASTER_EXPIRED_GS_CODE:
          case MASTER_TOKEN_INVALID_GS_CODE:
            throw new SnowflakeReauthenticationRequest(
                queryId, errorMessage, sqlState, errorCode);
        }
      }
      throw new SnowflakeSQLException(queryId, errorMessage, sqlState,
                                      errorCode);
    }