Skip to content

Commit 046daf6

Browse files
committed
chore(internal): construct error properties instead of using the raw response (#1257)
1 parent 73869ee commit 046daf6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Diff for: src/openai/_exceptions.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import httpx
99

1010
from ._utils import is_dict
11+
from ._models import construct_type
1112

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

5354
if is_dict(body):
54-
self.code = cast(Any, body.get("code"))
55-
self.param = cast(Any, body.get("param"))
56-
self.type = cast(Any, body.get("type"))
55+
self.code = cast(Any, construct_type(type_=Optional[str], value=body.get("code")))
56+
self.param = cast(Any, construct_type(type_=Optional[str], value=body.get("param")))
57+
self.type = cast(Any, construct_type(type_=str, value=body.get("type")))
5758
else:
5859
self.code = None
5960
self.param = None

0 commit comments

Comments
 (0)