onError method

  1. @internal
void onError(
  1. AsyncError<T> value, {
  2. bool seamless = false,
})
inherited

Life-cycle for when an error from the provider's "build" method is received.

Might be invoked after the element is disposed in the case where provider.future has yet to complete.

Implementation

@internal
void onError(AsyncError<T> value, {bool seamless = false}) {
  asyncTransition(value, seamless: seamless);

  for (final observer in container.observers) {
    runQuaternaryGuarded(
      observer.providerDidFail,
      provider,
      value.error,
      value.stackTrace,
      container,
    );
  }

  final completer = _futureCompleter;
  if (completer != null) {
    completer
      // TODO test ignore
      ..future.ignore()
      ..completeError(
        value.error,
        value.stackTrace,
      );
    _futureCompleter = null;
    // TODO SynchronousFuture.error
  } else {
    futureNotifier.result = Result.data(
      // TODO test ignore
      Future.error(
        value.error,
        value.stackTrace,
      )..ignore(),
    );
  }
}