@@ -440,33 +440,38 @@ def _should_return_none(self, response: httpx.Response) -> bool:
440440 response .content
441441 ) or (not response .headers .get ("location" ) and response .status_code in [301 , 302 ])
442442
443- async def throw_failed_responses (
444- self ,
445- response : httpx .Response ,
446- error_map : Optional [dict [str , type [ParsableFactory ]]],
447- parent_span : trace .Span ,
448- attribute_span : trace .Span ,
449- ) -> None :
450- if response .is_success or response .status_code == 304 :
451- return
443+ def _throw_empty_redirects (self , response : httpx .Response , parent_span : trace .Span , attribute_span : trace .Span ) -> None :
452444 if response .is_redirect :
453445 if response .has_redirect_location :
454446 return
455- # Raise a more specific error if the server returned a redirect status code without a location header
447+ # Raise a more specific error if the server returned a redirect status code
448+ # without a location header
456449 attribute_span .set_status (trace .StatusCode .ERROR )
457450 _throw_failed_resp_span = self ._start_local_tracing_span (
458451 "throw_failed_responses" , parent_span
459452 )
460453 _throw_failed_resp_span .set_attribute ("status" , response .status_code )
461454 exc = APIError (
462- f"The server returned a redirect status code { response .status_code } without a location header" ,
455+ f"The server returned a redirect status code { response .status_code } "
456+ " without a location header" ,
463457 response .status_code ,
464458 response .headers , # type: ignore
465459 )
466460 _throw_failed_resp_span .set_status (trace .StatusCode .ERROR , str (exc ))
467461 attribute_span .record_exception (exc )
468462 _throw_failed_resp_span .end ()
469463 raise exc
464+
465+ async def throw_failed_responses (
466+ self ,
467+ response : httpx .Response ,
468+ error_map : Optional [dict [str , type [ParsableFactory ]]],
469+ parent_span : trace .Span ,
470+ attribute_span : trace .Span ,
471+ ) -> None :
472+ if response .is_success or response .status_code == 304 :
473+ return
474+ self ._throw_empty_redirects (response , parent_span , attribute_span )
470475 try :
471476 attribute_span .set_status (trace .StatusCode .ERROR )
472477
0 commit comments