Skip to content

Commit 70949f7

Browse files
committed
add headers to api error
1 parent 9d95dde commit 70949f7

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/square/core/api_error.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,15 @@ class ApiError(Exception):
1717
status_code: Optional[int]
1818
body: Any
1919
errors: List[Error]
20-
21-
def __init__(self, *, status_code: Optional[int] = None, body: Any = None):
20+
headers: Optional[Dict[str, str]]
21+
22+
def __init__(
23+
self,
24+
*,
25+
headers: Optional[Dict[str, str]] = None,
26+
status_code: Optional[int] = None,
27+
body: Any = None,
28+
) -> None:
2229
"""
2330
Initialize an ApiError.
2431
@@ -30,6 +37,7 @@ def __init__(self, *, status_code: Optional[int] = None, body: Any = None):
3037
self.status_code = status_code
3138
self.body = body
3239
self.errors = self._parse_errors(body)
40+
self.headers = headers
3341

3442
super().__init__(self._build_message(message, status_code, body))
3543

@@ -120,4 +128,4 @@ def _parse_error(self, data: Optional[Dict[str, Any]] = None) -> Error:
120128
)
121129

122130
def __str__(self) -> str:
123-
return f"status_code: {self.status_code}, body: {self.body}"
131+
return f"headers: {self.headers}, status_code: {self.status_code}, body: {self.body}"

0 commit comments

Comments
 (0)