@@ -99,18 +99,20 @@ def partition(
9999 data = utils .unmarshal_json (http_res .text , errors .HTTPValidationErrorData )
100100 raise errors .HTTPValidationError (data = data )
101101 if utils .match_response (http_res , "4XX" , "*" ):
102+ http_res_text = utils .stream_to_text (http_res )
102103 raise errors .SDKError (
103- "API error occurred" , http_res .status_code , http_res . text , http_res
104+ "API error occurred" , http_res .status_code , http_res_text , http_res
104105 )
105106 if utils .match_response (http_res , "5XX" , "application/json" ):
106107 data = utils .unmarshal_json (http_res .text , errors .ServerErrorData )
107108 raise errors .ServerError (data = data )
108109
109110 content_type = http_res .headers .get ("Content-Type" )
111+ http_res_text = utils .stream_to_text (http_res )
110112 raise errors .SDKError (
111113 f"Unexpected response received (code: { http_res .status_code } , type: { content_type } )" ,
112114 http_res .status_code ,
113- http_res . text ,
115+ http_res_text ,
114116 http_res ,
115117 )
116118
@@ -204,17 +206,19 @@ async def partition_async(
204206 data = utils .unmarshal_json (http_res .text , errors .HTTPValidationErrorData )
205207 raise errors .HTTPValidationError (data = data )
206208 if utils .match_response (http_res , "4XX" , "*" ):
209+ http_res_text = await utils .stream_to_text_async (http_res )
207210 raise errors .SDKError (
208- "API error occurred" , http_res .status_code , http_res . text , http_res
211+ "API error occurred" , http_res .status_code , http_res_text , http_res
209212 )
210213 if utils .match_response (http_res , "5XX" , "application/json" ):
211214 data = utils .unmarshal_json (http_res .text , errors .ServerErrorData )
212215 raise errors .ServerError (data = data )
213216
214217 content_type = http_res .headers .get ("Content-Type" )
218+ http_res_text = await utils .stream_to_text_async (http_res )
215219 raise errors .SDKError (
216220 f"Unexpected response received (code: { http_res .status_code } , type: { content_type } )" ,
217221 http_res .status_code ,
218- http_res . text ,
222+ http_res_text ,
219223 http_res ,
220224 )
0 commit comments