Propogate only errors to an another future or array of futures.
966363
function(futures) {
		this.resolve(function(err) {
			if (!err) {
				return;
			}
			if (futures instanceof Array) {
				for (var ii = 0; ii < futures.length; ++ii) {
					futures[ii].throw(err);
				}
			} else {
				futures.throw(err);
			}
		});
		return this;
	}
269647
function(value) {
		if (this.resolved) {
			throw new Error('Future resolved more than once');
		}
		this.value = value;
		this.resolved = true;

		var callbacks = this.callbacks;
		if (callbacks) {
			delete this.callbacks;
			for (var ii = 0; ii < callbacks.length; ++ii) {
				try {
					var ref = callbacks[ii];
					if (ref[1]) {
						ref[1](value);
					} else {
						ref[0](undefined, value);
					}
				} catch(ex) {
					// console.log('Resolve cb threw', String(ex.stack || ex.message || ex));
					process.nextTick(function() {
						throw(ex);
					});
				}
			}
		}
	}
1013230
private void findErrors(final Span references[], final Span predictions[],
      final List<Span> falseNegatives, final List<Span> falsePositives) {

    falseNegatives.addAll(Arrays.asList(references));
    falsePositives.addAll(Arrays.asList(predictions));

    for (final Span referenceName : references) {

      for (final Span prediction : predictions) {
        if (referenceName.equals(prediction)) {
          // got it, remove from fn and fp
          falseNegatives.remove(referenceName);
          falsePositives.remove(prediction);
        }
      }
    }
  }
79839
private CompletableFuture<T> orderedFuture() {
    if (!complete) {
      synchronized (orderedFutures) {
        if (!complete) {
          CompletableFuture<T> future = new CompletableFuture<>();
          orderedFutures.add(future);
          return future;
        }
      }
    }

    // Completed
    if (error == null) {
      return CompletableFuture.completedFuture(result);
    } else {
      return Futures.exceptionalFuture(error);
    }
  }
475591
private static <T> void cancelAll(ArrayList<Future<T>> futures, int j) {
        for (int size = futures.size(); j < size; j++)
            futures.get(j).cancel(true);
    }
501206
def ensure_future(fut, *, loop=None):
    
    if sys.version_info < (3, 4, 4):
        # This is to avoid a SyntaxError on 3.7.0a2+
        func = getattr(asyncio, "async")
    else:
        func = asyncio.ensure_future

    return func(fut, loop=loop)
211646
function(errors) {
      return errors
        .map(function(error) { return error.error; })
        .filter(function(value, index, self) {
          return self.indexOf(value) === index;
        });
    }
719989
function FutureJoin(first) {
        Future.call(this);

        this.first = first;
        this.missing = first instanceof Future && first.state === STATE_LISTEN ? 1 : 0;
    }
999756
def create_future(loop):
    # pragma: no cover
    """"""
    if hasattr(loop, 'create_future'):
        return loop.create_future()
    return asyncio.Future(loop=loop)
503045
private void complete(T result, Throwable error) {
    synchronized (orderedFutures) {
      this.result = result;
      this.error = error;
      this.complete = true;
      if (error == null) {
        for (CompletableFuture<T> future : orderedFutures) {
          future.complete(result);
        }
      } else {
        for (CompletableFuture<T> future : orderedFutures) {
          future.completeExceptionally(error);
        }
      }
      orderedFutures.clear();
    }
  }
149543
def until_all_children_in_state(self, state, timeout=None):
        """"""
        futures = [r.until_state(state, timeout=timeout)
                   for r in dict.values(self.children)]
        yield tornado.gen.multi(futures, quiet_exceptions=tornado.gen.TimeoutError)
1235326
public static <T> @NonNull CompletableFuture<T> immediateFailedFuture(final @NonNull Throwable ex) {
    final CompletableFuture<T> future = new CompletableFuture<>();
    future.completeExceptionally(ex);
    return future;
  }
316907
def _future_completed(future):
    
    exc = future.exception()
    if exc:
        log.debug("Failed to run task on executor", exc_info=exc)
822908
function callNext(list, results, propogate) {
    var ret = new Promise().callback();
    forEach(list, function (listItem) {
        ret = ret.chain(propogate ? listItem : bindIgnore(null, listItem));
        if (!propogate) {
            ret.addCallback(function (res) {
                results.push(res);
                res = null;
            });
        }
    });
    return propogate ? ret.promise() : ret.chain(results);
}
838914
private void connect(int attempt, CompletableFuture<SessionClient> future) {
    if (attempt > MAX_ATTEMPTS) {
      future.completeExceptionally(new PrimitiveException.Unavailable());
      return;
    }

    primaryElection.getTerm().whenCompleteAsync((term, error) -> {
      if (error == null) {
        if (term.primary() == null) {
          future.completeExceptionally(new PrimitiveException.Unavailable());
        } else {
          this.term = term;
          protocol.registerEventListener(sessionId, this::handleEvent, threadContext);
          future.complete(this);
        }
      } else {
        Throwable cause = Throwables.getRootCause(error);
        if (cause instanceof PrimitiveException.Unavailable || cause instanceof TimeoutException) {
          threadContext.schedule(Duration.ofMillis(RETRY_DELAY), () -> connect(attempt + 1, future));
        } else {
          future.completeExceptionally(new PrimitiveException.Unavailable());
        }
      }
    }, threadContext);
  }
1365478
public static <A> Will<A> forFuture(Future<A> future) {
        return forListenableFuture(JdkFutureAdapters.listenInPoolThread(future));
    }
435950
public static <V> FutureCombiner<V> whenAllComplete(
      Iterable<? extends ListenableFuture<? extends V>> futures) {
    return new FutureCombiner<V>(false, ImmutableList.copyOf(futures));
  }