"""Shared response parsing for owsclient calls.""" from __future__ import annotations from typing import Any from src.errors import PermanentError, TransientError def parse_json_response(service: str, resp: Any) -> Any: if resp.status_code >= 500: raise TransientError(f"{service} returned {resp.status_code}: {resp.text[:200]}") if resp.status_code >= 400: raise PermanentError(f"{service} returned {resp.status_code}: {resp.text[:200]}") try: return resp.json() except Exception as exc: raise TransientError(f"{service} returned non-JSON response: {resp.text[:200]}") from exc