shamblett / cbor

A CBOR implementation for Dart
MIT License
36 stars 15 forks source link

Bad state: No element #26

Closed samigimix closed 2 years ago

samigimix commented 2 years ago

Hello, I got this error after call getDecodedData() and the value is a list of int

var value = await c.read();
final cbor = Cbor();
final payloadBuffer = Uint8Buffer();
payloadBuffer.addAll(value);
cbor.decodeFromBuffer(payloadBuffer);
cbor.getDecodedData();

E/flutter (10236): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Bad state: No element E/flutter (10236): #0 ListQueue.last (dart:collection/queue.dart:623:25) E/flutter (10236): #1 Stack.pop package:cbor/src/cbor_stack.dart:33 E/flutter (10236): #2 ItemStack.pop package:cbor/src/cbor_item_stack.dart:35 E/flutter (10236): #3 DecodeStack._processIterable package:cbor/src/cbor_decode_stack.dart:96 E/flutter (10236): #4 DecodeStack._processIterable package:cbor/src/cbor_decode_stack.dart:100 E/flutter (10236): #5 DecodeStack.build package:cbor/src/cbor_decode_stack.dart:56 E/flutter (10236): #6 Cbor.getDecodedData package:cbor/src/cbor.dart:65

shamblett commented 2 years ago

OK, I'm going to need to know what 'value' is , i.e. what are you trying to decode exactly? Please add a print(value) when its been assigned.

samigimix commented 2 years ago

The issue occurred because of the sender bug.