@@ -189,6 +189,7 @@ def uipath_request(
189189 url : URL | str = "/" ,
190190 * ,
191191 request_body : dict [str , Any ] | None = None ,
192+ raise_status_error : bool = False ,
192193 ** kwargs : Any ,
193194 ) -> Response :
194195 """Make a synchronous HTTP request to the UiPath API.
@@ -205,18 +206,25 @@ def uipath_request(
205206 Raises:
206207 UiPathAPIError: On HTTP 4xx/5xx responses (raised by transport layer).
207208 """
208- return self .uipath_sync_client .request (method , url , json = request_body , ** kwargs )
209+ response = self .uipath_sync_client .request (method , url , json = request_body , ** kwargs )
210+ if raise_status_error :
211+ response .raise_for_status ()
212+ return response
209213
210214 async def uipath_arequest (
211215 self ,
212216 method : Literal ["POST" , "GET" ] = "POST" ,
213217 url : URL | str = "/" ,
214218 * ,
215219 request_body : dict [str , Any ] | None = None ,
220+ raise_status_error : bool = False ,
216221 ** kwargs : Any ,
217222 ) -> Response :
218223 """Make an asynchronous HTTP request to the UiPath API."""
219- return await self .uipath_async_client .request (method , url , json = request_body , ** kwargs )
224+ response = await self .uipath_async_client .request (method , url , json = request_body , ** kwargs )
225+ if raise_status_error :
226+ response .raise_for_status ()
227+ return response
220228
221229 def uipath_stream (
222230 self ,
@@ -225,6 +233,7 @@ def uipath_stream(
225233 * ,
226234 request_body : dict [str , Any ] | None = None ,
227235 stream_type : Literal ["text" , "bytes" , "lines" , "raw" ] = "lines" ,
236+ raise_status_error : bool = False ,
228237 ** kwargs : Any ,
229238 ) -> Iterator [str | bytes ]:
230239 """Make a synchronous streaming HTTP request to the UiPath API.
@@ -244,6 +253,8 @@ def uipath_stream(
244253 str | bytes: Chunks of the streaming response.
245254 """
246255 with self .uipath_sync_client .stream (method , url , json = request_body , ** kwargs ) as response :
256+ if raise_status_error :
257+ response .raise_for_status ()
247258 match stream_type :
248259 case "text" :
249260 for chunk in response .iter_text ():
@@ -265,6 +276,7 @@ async def uipath_astream(
265276 * ,
266277 request_body : dict [str , Any ] | None = None ,
267278 stream_type : Literal ["text" , "bytes" , "lines" , "raw" ] = "lines" ,
279+ raise_status_error : bool = False ,
268280 ** kwargs : Any ,
269281 ) -> AsyncIterator [str | bytes ]:
270282 """Make an asynchronous streaming HTTP request to the UiPath API.
@@ -286,6 +298,8 @@ async def uipath_astream(
286298 async with self .uipath_async_client .stream (
287299 method , url , json = request_body , ** kwargs
288300 ) as response :
301+ if raise_status_error :
302+ response .raise_for_status ()
289303 match stream_type :
290304 case "text" :
291305 async for chunk in response .aiter_text ():
0 commit comments