docs: private void autoSelectVersionAndError() {
  		if (qr.version == -1) {
  			QrCode.ErrorLevel levelsToTry[];
  			if (autoErrorCorrection) {
  				// this is a reasonable compromise between robustness and data storage
  				levelsToTry = new QrCode.ErrorLevel[]{QrCode.ErrorLevel.M,QrCode.ErrorLevel.L};
  			} else {
  				levelsToTry = new QrCode.ErrorLevel[]{qr.error};
  			}
  			escape:for( QrCode.ErrorLevel error : levelsToTry ) {
  				qr.error = error;
  				// select the smallest version which can store all the data
  				for (int i = 1; i <= 40; i++) {
  					int dataBits = bitsAtVersion(i);
  					int totalBytes = dataBits / 8 + (dataBits % 8) % 8;
  					if (totalBytes <= QrCode.VERSION_INFO[i].totalDataBytes(qr.error)) {
  						qr.version = i;
  						break escape;
  					}
  				}
  			}
  			if (qr.version == -1) {
  				throw new IllegalArgumentException("Packet too to be encoded in a qr code");
  			}
  		} else {
  			// the version is set but the error correction level isn't. Pick the one with
  			// the most error correction that can which can store all the data
  			if (autoErrorCorrection) {
  				qr.error = null;
  				QrCode.VersionInfo v = QrCode.VERSION_INFO[qr.version];
  				int dataBits = bitsAtVersion(qr.version);
  				int totalBytes = dataBits / 8 + (dataBits % 8) % 8;
  				for (QrCode.ErrorLevel level : QrCode.ErrorLevel.values()) {
  					if (totalBytes <= v.totalDataBytes(level)) {
  						qr.error = level;
  					}
  				}
  				if (qr.error == null) {
  					throw new IllegalArgumentException("You need to use a high version number to store the data. Tried " +
  							"all error correction levels at version " + qr.version + ". Total Data " + (packed.size / 8));
  				}
  			}
  		}
  		// Sanity check
  		int dataBits = bitsAtVersion(qr.version);
  		int totalBytes = dataBits / 8 + (dataBits % 8) % 8;
  		QrCode.VersionInfo v = QrCode.VERSION_INFO[qr.version];
  		if (totalBytes > v.totalDataBytes(qr.error)) {
  			throw new IllegalArgumentException("Version and error level can't encode all the data");
  		}
  	}