# This file was auto-generated by Fern from our API Definition.

from typing import Any, Dict, Optional


class ParsingError(Exception):
    """
    Raised when the SDK fails to parse/validate a response from the server.
    This typically indicates that the server returned a response whose shape
    does not match the expected schema.
    """

    headers: Optional[Dict[str, str]]
    status_code: Optional[int]
    body: Any
    cause: Optional[Exception]

    def __init__(
        self,
        *,
        headers: Optional[Dict[str, str]] = None,
        status_code: Optional[int] = None,
        body: Any = None,
        cause: Optional[Exception] = None,
    ) -> None:
        self.headers = headers
        self.status_code = status_code
        self.body = body
        self.cause = cause
        super().__init__()
        if cause is not None:
            self.__cause__ = cause

    def __str__(self) -> str:
        cause_str = f", cause: {self.cause}" if self.cause is not None else ""
        return f"headers: {self.headers}, status_code: {self.status_code}, body: {self.body}{cause_str}"
