diff --git a/src/square/core/api_error.py b/src/square/core/api_error.py index 59664655..426f851e 100644 --- a/src/square/core/api_error.py +++ b/src/square/core/api_error.py @@ -17,8 +17,15 @@ class ApiError(Exception): status_code: Optional[int] body: Any errors: List[Error] - - def __init__(self, *, status_code: Optional[int] = None, body: Any = None): + headers: Optional[Dict[str, str]] + + def __init__( + self, + *, + headers: Optional[Dict[str, str]] = None, + status_code: Optional[int] = None, + body: Any = None, + ) -> None: """ Initialize an ApiError. @@ -30,6 +37,7 @@ def __init__(self, *, status_code: Optional[int] = None, body: Any = None): self.status_code = status_code self.body = body self.errors = self._parse_errors(body) + self.headers = headers super().__init__(self._build_message(message, status_code, body)) @@ -120,4 +128,4 @@ def _parse_error(self, data: Optional[Dict[str, Any]] = None) -> Error: ) def __str__(self) -> str: - return f"status_code: {self.status_code}, body: {self.body}" + return f"headers: {self.headers}, status_code: {self.status_code}, body: {self.body}"