setError method

void setError (dynamic error, [ StackTrace stackTrace ])

Indicates that there was an error connecting the channel.

This makes the stream emit error and close. It makes the sink discard all its events.

Either setChannel or setError may be called at most once. Trying to call either of them again will fail.

Implementation

void setError(error, [StackTrace stackTrace]) {
  if (_set) throw new StateError("The channel has already been set.");
  _set = true;

  _streamCompleter.setError(error, stackTrace);
  _sinkCompleter.setDestinationSink(new NullStreamSink());
}