ErrorResponseMessage constructor

ErrorResponseMessage(
  1. Uint8List bytes
)

Implementation

ErrorResponseMessage(Uint8List bytes) {
  final reader = ByteDataReader()..add(bytes);

  int? identificationToken;
  StringBuffer? sb;

  while (reader.remainingLength > 0) {
    final byte = reader.readUint8();
    if (identificationToken == null) {
      identificationToken = byte;
      sb = StringBuffer();
    } else if (byte == 0) {
      fields.add(ErrorField(identificationToken, sb.toString()));
      identificationToken = null;
      sb = null;
    } else {
      sb!.writeCharCode(byte);
    }
  }
  if (identificationToken != null && sb != null) {
    fields.add(ErrorField(identificationToken, sb.toString()));
  }
}