docs: public SQLException handleIoException(Exception initialException) {
      boolean mustReconnect;
      boolean driverPreventError = false;
  
      if (initialException instanceof MaxAllowedPacketException) {
        mustReconnect = ((MaxAllowedPacketException) initialException).isMustReconnect();
        driverPreventError = !mustReconnect;
      } else {
        mustReconnect = writer.exceedMaxLength();
      }
  
      if (mustReconnect) {
        try {
          connect();
        } catch (SQLException queryException) {
          connected = false;
          return new SQLNonTransientConnectionException(initialException.getMessage()
              + "\nError during reconnection" + getTraces(), CONNECTION_EXCEPTION.getSqlState(),
              initialException);
        }
  
        try {
          resetStateAfterFailover(getMaxRows(), getTransactionIsolationLevel(), getDatabase(),
              getAutocommit());
        } catch (SQLException queryException) {
          return new SQLException("reconnection succeed, but resetting previous state failed",
              UNDEFINED_SQLSTATE.getSqlState() + getTraces(), initialException);
        }
  
        return new SQLTransientConnectionException("Could not send query: query size is >= to max_allowed_packet ("
            + writer.getMaxAllowedPacket() + ")" + getTraces(), UNDEFINED_SQLSTATE.getSqlState(),
            initialException);
      }
      if (!driverPreventError) {
        connected = false;
      }
      return new SQLNonTransientConnectionException(initialException.getMessage() + getTraces(),
          driverPreventError ? UNDEFINED_SQLSTATE.getSqlState() : CONNECTION_EXCEPTION.getSqlState(),
          initialException);
  
    }