injectError method

void injectError(
  1. Object error, [
  2. StackTrace? stackTrace
])

Simulates a connection failure by emitting error to the incoming stream, as a real transport would on socket error.

Implementation

void injectError(Object error, [StackTrace? stackTrace]) {
  if (_closed) {
    return;
  }
  _connected = false;
  _incoming.addError(error, stackTrace ?? StackTrace.current);
}