Future.error factory constructor
Future.error(A future that completes with an error in the next event-loop iteration.
If error
is null
, it is replaced by a NullThrownError.
Use Completer to create a future and complete it later.
Source
factory Future.error(Object error, [StackTrace stackTrace]) { error = _nonNullError(error); if (!identical(Zone.current, _ROOT_ZONE)) { AsyncError replacement = Zone.current.errorCallback(error, stackTrace); if (replacement != null) { error = _nonNullError(replacement.error); stackTrace = replacement.stackTrace; } } return new _Future<T>.immediateError(error, stackTrace); }
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/1.24.3/dart-async/Future/Future.error.html