Skip to content

Commit

Permalink
chore(internal): construct error properties instead of using the raw …
Browse files Browse the repository at this point in the history
…response (#1257)
  • Loading branch information
stainless-bot committed Mar 21, 2024
1 parent 5887858 commit 11dce5c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/openai/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import httpx

from ._utils import is_dict
from ._models import construct_type

__all__ = [
"BadRequestError",
Expand Down Expand Up @@ -51,9 +52,9 @@ def __init__(self, message: str, request: httpx.Request, *, body: object | None)
self.body = body

if is_dict(body):
self.code = cast(Any, body.get("code"))
self.param = cast(Any, body.get("param"))
self.type = cast(Any, body.get("type"))
self.code = cast(Any, construct_type(type_=Optional[str], value=body.get("code")))
self.param = cast(Any, construct_type(type_=Optional[str], value=body.get("param")))
self.type = cast(Any, construct_type(type_=str, value=body.get("type")))
else:
self.code = None
self.param = None
Expand Down

0 comments on commit 11dce5c

Please sign in to comment.