private CompletableFuture<Location> locationAsync(int attempt) {
    return getStackFrameAsync()
      .thenCompose(frame -> {
        try {
          return CompletableFuture.completedFuture(frame.location());
        }
        catch (InvalidStackFrameException e) {
          if (attempt > 0) {
            return locationAsync(attempt - 1);
          }
          throw new CompletionException(new EvaluateException(e.getMessage(), e));
        }
      });
  }
private CompletableFuture<Location> locationAsync(int attempt)