ErrorResponseMessage constructor
Implementation
ErrorResponseMessage(Uint8List bytes, Encoding encoding) {
final reader = ByteDataReader()..add(bytes);
int? identificationToken;
List<int> currentFieldBytes = [];
while (reader.remainingLength > 0) {
final byte = reader.readUint8();
if (identificationToken == null) {
identificationToken = byte;
currentFieldBytes = [];
} else if (byte == 0) {
fields.add(ErrorField(
identificationToken, encoding.decode(currentFieldBytes)));
identificationToken = null;
} else {
currentFieldBytes.add(byte);
}
}
if (identificationToken != null && currentFieldBytes.isNotEmpty) {
fields.add(
ErrorField(identificationToken, encoding.decode(currentFieldBytes)));
}
}