Skip to content

Commit abb60d4

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat(api): update via SDK Studio (#159)
1 parent 15686e4 commit abb60d4

File tree

5 files changed

+36
-1
lines changed

5 files changed

+36
-1
lines changed

api.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Shared Types
2+
3+
```python
4+
from cloudflare.types import ErrorData
5+
```
6+
17
# Accounts
28

39
Types:

src/cloudflare/_exceptions.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@
22

33
from __future__ import annotations
44

5+
from typing import Any, List, cast
56
from typing_extensions import Literal
67

78
import httpx
89

10+
from ._utils import is_dict
11+
from ._models import construct_type
12+
from .types.shared import ErrorData
13+
914
__all__ = [
1015
"BadRequestError",
1116
"AuthenticationError",
@@ -37,12 +42,19 @@ class APIError(CloudflareError):
3742
If there was no response associated with this error then it will be `None`.
3843
"""
3944

40-
def __init__(self, message: str, request: httpx.Request, *, body: object | None) -> None: # noqa: ARG002
45+
errors: List[ErrorData]
46+
47+
def __init__(self, message: str, request: httpx.Request, *, body: object | None) -> None:
4148
super().__init__(message)
4249
self.request = request
4350
self.message = message
4451
self.body = body
4552

53+
if is_dict(body):
54+
self.errors = cast(Any, construct_type(type_=List[ErrorData], value=body.get("errors")))
55+
else:
56+
self.errors = []
57+
4658

4759
class APIResponseValidationError(APIError):
4860
response: httpx.Response

src/cloudflare/types/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from .ips import IPs as IPs
66
from .zone import Zone as Zone
7+
from .shared import ErrorData as ErrorData
78
from .account import Account as Account
89
from .snippet import Snippet as Snippet
910
from .calls_app import CallsApp as CallsApp
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from .error_data import ErrorData as ErrorData
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import Optional
4+
5+
from ..._models import BaseModel
6+
7+
__all__ = ["ErrorData"]
8+
9+
10+
class ErrorData(BaseModel):
11+
code: Optional[int] = None
12+
13+
message: Optional[str] = None

0 commit comments

Comments
 (0)