@@ -19,13 +19,12 @@ class User(BubbleModel, typename="user"):
1919from collections .abc import AsyncIterator
2020from datetime import datetime
2121
22- import httpx
2322from pydantic import BaseModel as PydanticBaseModel
2423from pydantic import Field
2524
2625from bubble_data_api_client .client .raw_client import AdditionalSortField , RawClient
2726from bubble_data_api_client .constraints import Constraint , ConstraintType , constraint
28- from bubble_data_api_client .exceptions import UnknownFieldError
27+ from bubble_data_api_client .exceptions import BubbleAPIError , UnknownFieldError
2928from bubble_data_api_client .types import BubbleField , OnMultiple
3029
3130
@@ -91,7 +90,6 @@ async def create(cls, **data: typing.Any) -> typing.Self:
9190 aliased_data = cls ._resolve_aliases (data )
9291 async with _get_client () as client :
9392 response = await client .create (cls ._typename , aliased_data )
94- response .raise_for_status ()
9593 uid = response .json ()["id" ]
9694 return cls (** aliased_data , ** {BubbleField .ID : uid })
9795
@@ -101,10 +99,9 @@ async def get(cls, uid: str) -> typing.Self | None:
10199 async with _get_client () as client :
102100 try :
103101 response = await client .retrieve (cls ._typename , uid )
104- response .raise_for_status ()
105102 return cls (** response .json ()["response" ])
106- except httpx . HTTPStatusError as e :
107- if e .response . status_code == http .HTTPStatus .NOT_FOUND :
103+ except BubbleAPIError as e :
104+ if e .status_code == http .HTTPStatus .NOT_FOUND :
108105 return None
109106 raise
110107
@@ -130,22 +127,19 @@ async def save(self) -> None:
130127 exclude = {"uid" , "created_date" , "modified_date" , "slug" },
131128 by_alias = True ,
132129 )
133- response = await client .update (self ._typename , self .uid , data )
134- response .raise_for_status ()
130+ await client .update (self ._typename , self .uid , data )
135131
136132 @classmethod
137133 async def update (cls , uid : str , ** data : typing .Any ) -> None :
138134 """Update specific fields on a thing by its unique ID."""
139135 aliased_data = cls ._resolve_aliases (data )
140136 async with _get_client () as client :
141- response = await client .update (cls ._typename , uid , aliased_data )
142- response .raise_for_status ()
137+ await client .update (cls ._typename , uid , aliased_data )
143138
144139 async def delete (self ) -> None :
145140 """Delete this thing from Bubble."""
146141 async with _get_client () as client :
147- response = await client .delete (self ._typename , self .uid )
148- response .raise_for_status ()
142+ await client .delete (self ._typename , self .uid )
149143
150144 @classmethod
151145 async def find (
@@ -184,7 +178,6 @@ async def find(
184178 exclude_remaining = exclude_remaining ,
185179 additional_sort_fields = additional_sort_fields ,
186180 )
187- response .raise_for_status ()
188181 return [cls (** item ) for item in response .json ()["response" ]["results" ]]
189182
190183 @classmethod
@@ -210,7 +203,6 @@ async def find_iter(
210203 descending = descending ,
211204 additional_sort_fields = additional_sort_fields ,
212205 )
213- response .raise_for_status ()
214206 body = response .json ()["response" ]
215207 for item in body ["results" ]:
216208 yield cls (** item )
0 commit comments