execute method
Implementation
Map<String, dynamic> execute(final dynamic data) {
final decoded = core.cbor.decode(_framePayload(data));
if (decoded is! List || decoded.length < 2) {
throw const FirehoseFrameException(
'A firehose frame must be a 2-element CBOR sequence',
);
}
final header = decoded[0];
final body = decoded[1];
if (header is! Map || body is! Map) {
throw const FirehoseFrameException(
'A firehose frame header and body must both be CBOR maps',
);
}
final merged = <String, dynamic>{...header, ...body};
//! Error frames use `op == -1` and carry `{error, message}` instead of a
//! message type (`t`). Surface them as a typed exception.
if (merged['op'] == -1) {
throw FirehoseErrorException(
error: merged['error']?.toString() ?? 'Unknown',
message: merged['message']?.toString(),
);
}
return merged;
}