(data: Any, body: Any)
| 324 | |
| 325 | |
| 326 | def _parse_envelope(data: Any, body: Any) -> Any: |
| 327 | # The generated layer may hand us a deserialized model, a dict, or a raw |
| 328 | # string body. Prefer a dict-shaped value; fall back to JSON-parsing body. |
| 329 | if isinstance(data, dict): |
| 330 | return data |
| 331 | if hasattr(data, "to_dict"): |
| 332 | try: |
| 333 | return data.to_dict() |
| 334 | except Exception: # pragma: no cover - defensive |
| 335 | pass |
| 336 | if isinstance(body, (str, bytes)): |
| 337 | try: |
| 338 | return json.loads(body) |
| 339 | except (ValueError, TypeError): |
| 340 | return None |
| 341 | return None |
| 342 | |
| 343 | |
| 344 | def connection_error(message: str, cause: Optional[BaseException] = None) -> E2AConnectionError: |
no test coverage detected