emitsError function

StreamMatcher emitsError(
  1. Object? matcher
)

Returns a StreamMatcher that matches a single error event that matches matcher.

Implementation

StreamMatcher emitsError(Object? matcher) {
  var wrapped = wrapMatcher(matcher);
  var matcherDescription = wrapped.describe(StringDescription());
  var throwsMatcher = throwsA(wrapped) as AsyncMatcher;

  return StreamMatcher(
      (queue) => throwsMatcher.matchAsync(queue.next) as Future<String?>,
      // TODO(nweiz): add "should" once matcher#42 is fixed.
      'emit an error that $matcherDescription');
}