private void onError(Throwable error) {
    error = translateException(error);
    if (tries > startLogErrorsCnt) {
      LOG.warn("Call to " + loc.getServerName() + " for scanner id = " + scannerId + " for "
        + loc.getRegion().getEncodedName() + " of " + loc.getRegion().getTable()
        + " failed, , tries = " + tries + ", maxAttempts = " + maxAttempts + ", timeout = "
        + TimeUnit.NANOSECONDS.toMillis(scanTimeoutNs) + " ms, time elapsed = " + elapsedMs()
        + " ms", error);
    }
    boolean scannerClosed =
      error instanceof UnknownScannerException || error instanceof NotServingRegionException
        || error instanceof RegionServerStoppedException || error instanceof ScannerResetException;
    RetriesExhaustedException.ThrowableWithExtraContext qt =
      new RetriesExhaustedException.ThrowableWithExtraContext(error,
        EnvironmentEdgeManager.currentTime(), "");
    exceptions.add(qt);
    if (tries >= maxAttempts) {
      completeExceptionally(!scannerClosed);
      return;
    }

    OptionalLong maybePauseNsToUse =
      pauseManager.getPauseNsFromException(error, tries, nextCallStartNs);
    if (!maybePauseNsToUse.isPresent()) {
      completeExceptionally(!scannerClosed);
      return;
    }
    long delayNs = maybePauseNsToUse.getAsLong();
    if (scannerClosed) {
      completeWhenError(false);
      return;
    }
    if (error instanceof OutOfOrderScannerNextException) {
      completeWhenError(true);
      return;
    }
    if (error instanceof DoNotRetryIOException) {
      completeExceptionally(true);
      return;
    }
    tries++;

    if (HBaseServerException.isServerOverloaded(error)) {
      Optional<MetricsConnection> metrics = conn.getConnectionMetrics();
      metrics.ifPresent(m -> m.incrementServerOverloadedBackoffTime(delayNs, TimeUnit.NANOSECONDS));
    }
    retryTimer.newTimeout(t -> call(), delayNs, TimeUnit.NANOSECONDS);
  }
This method is used when {@link ScanControllerImpl#suspend} had ever been called to get a
{@link ScanResumerImpl}, but now user stops scan and does not need any more scan results.
hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncScanSingleRegionRpcRetryingCaller.java