from typing import Any from httpx import HTTPStatusError def get_error_details(exception: Exception) -> tuple[int | None, dict[str, Any] | None]: """Parse exception to get response data.""" if not isinstance(exception, HTTPStatusError) or not exception.response: return None, None status_code = exception.response.status_code try: data = exception.response.json() except Exception: data = None return status_code, data