cast<T> method
Casts the value of the CborObject
to the specified type,
or throws a MessageException
if casting fails.
Implementation
T cast<T>([String? onError]) {
try {
return this as T;
} catch (e) {
throw MessageException(onError ?? "Failed to cast CBOR object",
details: {"Type": "$T", "Value": value});
}
}