@@ -99,18 +99,20 @@ def partition(
99
99
data = utils .unmarshal_json (http_res .text , errors .HTTPValidationErrorData )
100
100
raise errors .HTTPValidationError (data = data )
101
101
if utils .match_response (http_res , "4XX" , "*" ):
102
+ http_res_text = utils .stream_to_text (http_res )
102
103
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
104
105
)
105
106
if utils .match_response (http_res , "5XX" , "application/json" ):
106
107
data = utils .unmarshal_json (http_res .text , errors .ServerErrorData )
107
108
raise errors .ServerError (data = data )
108
109
109
110
content_type = http_res .headers .get ("Content-Type" )
111
+ http_res_text = utils .stream_to_text (http_res )
110
112
raise errors .SDKError (
111
113
f"Unexpected response received (code: { http_res .status_code } , type: { content_type } )" ,
112
114
http_res .status_code ,
113
- http_res . text ,
115
+ http_res_text ,
114
116
http_res ,
115
117
)
116
118
@@ -204,17 +206,19 @@ async def partition_async(
204
206
data = utils .unmarshal_json (http_res .text , errors .HTTPValidationErrorData )
205
207
raise errors .HTTPValidationError (data = data )
206
208
if utils .match_response (http_res , "4XX" , "*" ):
209
+ http_res_text = await utils .stream_to_text_async (http_res )
207
210
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
209
212
)
210
213
if utils .match_response (http_res , "5XX" , "application/json" ):
211
214
data = utils .unmarshal_json (http_res .text , errors .ServerErrorData )
212
215
raise errors .ServerError (data = data )
213
216
214
217
content_type = http_res .headers .get ("Content-Type" )
218
+ http_res_text = await utils .stream_to_text_async (http_res )
215
219
raise errors .SDKError (
216
220
f"Unexpected response received (code: { http_res .status_code } , type: { content_type } )" ,
217
221
http_res .status_code ,
218
- http_res . text ,
222
+ http_res_text ,
219
223
http_res ,
220
224
)
0 commit comments