StreamChannel bind()

in lib/src/utils.dart [61:70]


  StreamChannel<Object?> bind(StreamChannel<Object?> channel) {
    return channel.changeStream((stream) {
      return stream.handleError((dynamic error) {
        final formatException = error as FormatException;
        var exception = RpcException(
            error_code.PARSE_ERROR, 'Invalid JSON: ${formatException.message}');
        channel.sink.add(exception.serialize(formatException.source));
      }, test: (error) => error is FormatException);
    });
  }