Skip to content

Commit

Permalink
feat(errors): add request_id property (#1317)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed Apr 15, 2024
1 parent 2f759aa commit f9eb77d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/openai/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ class APIStatusError(APIError):

response: httpx.Response
status_code: int
request_id: str | None

def __init__(self, message: str, *, response: httpx.Response, body: object | None) -> None:
super().__init__(message, response.request, body=body)
self.response = response
self.status_code = response.status_code
self.request_id = response.headers.get("x-request-id")


class APIConnectionError(APIError):
Expand Down

0 comments on commit f9eb77d

Please sign in to comment.