@@ -107,20 +107,29 @@ partial void ProcessGetSubtitlesResponseContent(
107107 if ( ( int ) __response . StatusCode == 400 )
108108 {
109109 string ? __content_400 = null ;
110+ global ::System . Exception ? __exception_400 = null ;
110111 global ::AssemblyAI . Error ? __value_400 = null ;
111- if ( ReadResponseAsString )
112+ try
112113 {
113- __content_400 = await __response . Content . ReadAsStringAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
114- __value_400 = global ::AssemblyAI . Error . FromJson ( __content_400 , JsonSerializerContext ) ;
114+ if ( ReadResponseAsString )
115+ {
116+ __content_400 = await __response . Content . ReadAsStringAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
117+ __value_400 = global ::AssemblyAI . Error . FromJson ( __content_400 , JsonSerializerContext ) ;
118+ }
119+ else
120+ {
121+ var __contentStream_400 = await __response . Content . ReadAsStreamAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
122+ __value_400 = await global ::AssemblyAI . Error . FromJsonStreamAsync ( __contentStream_400 , JsonSerializerContext ) . ConfigureAwait ( false ) ;
123+ }
115124 }
116- else
125+ catch ( global :: System . Exception __ex )
117126 {
118- var __contentStream_400 = await __response . Content . ReadAsStreamAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
119- __value_400 = await global ::AssemblyAI . Error . FromJsonStreamAsync ( __contentStream_400 , JsonSerializerContext ) . ConfigureAwait ( false ) ;
127+ __exception_400 = __ex ;
120128 }
121129
122130 throw new global ::AssemblyAI . ApiException < global ::AssemblyAI . Error > (
123131 message : __content_400 ?? __response . ReasonPhrase ?? string . Empty ,
132+ innerException : __exception_400 ,
124133 statusCode : __response . StatusCode )
125134 {
126135 ResponseBody = __content_400 ,
@@ -135,20 +144,29 @@ partial void ProcessGetSubtitlesResponseContent(
135144 if ( ( int ) __response . StatusCode == 401 )
136145 {
137146 string ? __content_401 = null ;
147+ global ::System . Exception ? __exception_401 = null ;
138148 global ::AssemblyAI . Error ? __value_401 = null ;
139- if ( ReadResponseAsString )
149+ try
140150 {
141- __content_401 = await __response . Content . ReadAsStringAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
142- __value_401 = global ::AssemblyAI . Error . FromJson ( __content_401 , JsonSerializerContext ) ;
151+ if ( ReadResponseAsString )
152+ {
153+ __content_401 = await __response . Content . ReadAsStringAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
154+ __value_401 = global ::AssemblyAI . Error . FromJson ( __content_401 , JsonSerializerContext ) ;
155+ }
156+ else
157+ {
158+ var __contentStream_401 = await __response . Content . ReadAsStreamAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
159+ __value_401 = await global ::AssemblyAI . Error . FromJsonStreamAsync ( __contentStream_401 , JsonSerializerContext ) . ConfigureAwait ( false ) ;
160+ }
143161 }
144- else
162+ catch ( global :: System . Exception __ex )
145163 {
146- var __contentStream_401 = await __response . Content . ReadAsStreamAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
147- __value_401 = await global ::AssemblyAI . Error . FromJsonStreamAsync ( __contentStream_401 , JsonSerializerContext ) . ConfigureAwait ( false ) ;
164+ __exception_401 = __ex ;
148165 }
149166
150167 throw new global ::AssemblyAI . ApiException < global ::AssemblyAI . Error > (
151168 message : __content_401 ?? __response . ReasonPhrase ?? string . Empty ,
169+ innerException : __exception_401 ,
152170 statusCode : __response . StatusCode )
153171 {
154172 ResponseBody = __content_401 ,
@@ -163,20 +181,29 @@ partial void ProcessGetSubtitlesResponseContent(
163181 if ( ( int ) __response . StatusCode == 404 )
164182 {
165183 string ? __content_404 = null ;
184+ global ::System . Exception ? __exception_404 = null ;
166185 global ::AssemblyAI . Error ? __value_404 = null ;
167- if ( ReadResponseAsString )
186+ try
168187 {
169- __content_404 = await __response . Content . ReadAsStringAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
170- __value_404 = global ::AssemblyAI . Error . FromJson ( __content_404 , JsonSerializerContext ) ;
188+ if ( ReadResponseAsString )
189+ {
190+ __content_404 = await __response . Content . ReadAsStringAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
191+ __value_404 = global ::AssemblyAI . Error . FromJson ( __content_404 , JsonSerializerContext ) ;
192+ }
193+ else
194+ {
195+ var __contentStream_404 = await __response . Content . ReadAsStreamAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
196+ __value_404 = await global ::AssemblyAI . Error . FromJsonStreamAsync ( __contentStream_404 , JsonSerializerContext ) . ConfigureAwait ( false ) ;
197+ }
171198 }
172- else
199+ catch ( global :: System . Exception __ex )
173200 {
174- var __contentStream_404 = await __response . Content . ReadAsStreamAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
175- __value_404 = await global ::AssemblyAI . Error . FromJsonStreamAsync ( __contentStream_404 , JsonSerializerContext ) . ConfigureAwait ( false ) ;
201+ __exception_404 = __ex ;
176202 }
177203
178204 throw new global ::AssemblyAI . ApiException < global ::AssemblyAI . Error > (
179205 message : __content_404 ?? __response . ReasonPhrase ?? string . Empty ,
206+ innerException : __exception_404 ,
180207 statusCode : __response . StatusCode )
181208 {
182209 ResponseBody = __content_404 ,
@@ -191,20 +218,29 @@ partial void ProcessGetSubtitlesResponseContent(
191218 if ( ( int ) __response . StatusCode == 429 )
192219 {
193220 string ? __content_429 = null ;
221+ global ::System . Exception ? __exception_429 = null ;
194222 global ::AssemblyAI . Error ? __value_429 = null ;
195- if ( ReadResponseAsString )
223+ try
196224 {
197- __content_429 = await __response . Content . ReadAsStringAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
198- __value_429 = global ::AssemblyAI . Error . FromJson ( __content_429 , JsonSerializerContext ) ;
225+ if ( ReadResponseAsString )
226+ {
227+ __content_429 = await __response . Content . ReadAsStringAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
228+ __value_429 = global ::AssemblyAI . Error . FromJson ( __content_429 , JsonSerializerContext ) ;
229+ }
230+ else
231+ {
232+ var __contentStream_429 = await __response . Content . ReadAsStreamAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
233+ __value_429 = await global ::AssemblyAI . Error . FromJsonStreamAsync ( __contentStream_429 , JsonSerializerContext ) . ConfigureAwait ( false ) ;
234+ }
199235 }
200- else
236+ catch ( global :: System . Exception __ex )
201237 {
202- var __contentStream_429 = await __response . Content . ReadAsStreamAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
203- __value_429 = await global ::AssemblyAI . Error . FromJsonStreamAsync ( __contentStream_429 , JsonSerializerContext ) . ConfigureAwait ( false ) ;
238+ __exception_429 = __ex ;
204239 }
205240
206241 throw new global ::AssemblyAI . ApiException < global ::AssemblyAI . Error > (
207242 message : __content_429 ?? __response . ReasonPhrase ?? string . Empty ,
243+ innerException : __exception_429 ,
208244 statusCode : __response . StatusCode )
209245 {
210246 ResponseBody = __content_429 ,
@@ -219,20 +255,29 @@ partial void ProcessGetSubtitlesResponseContent(
219255 if ( ( int ) __response . StatusCode == 500 )
220256 {
221257 string ? __content_500 = null ;
258+ global ::System . Exception ? __exception_500 = null ;
222259 global ::AssemblyAI . Error ? __value_500 = null ;
223- if ( ReadResponseAsString )
260+ try
224261 {
225- __content_500 = await __response . Content . ReadAsStringAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
226- __value_500 = global ::AssemblyAI . Error . FromJson ( __content_500 , JsonSerializerContext ) ;
262+ if ( ReadResponseAsString )
263+ {
264+ __content_500 = await __response . Content . ReadAsStringAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
265+ __value_500 = global ::AssemblyAI . Error . FromJson ( __content_500 , JsonSerializerContext ) ;
266+ }
267+ else
268+ {
269+ var __contentStream_500 = await __response . Content . ReadAsStreamAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
270+ __value_500 = await global ::AssemblyAI . Error . FromJsonStreamAsync ( __contentStream_500 , JsonSerializerContext ) . ConfigureAwait ( false ) ;
271+ }
227272 }
228- else
273+ catch ( global :: System . Exception __ex )
229274 {
230- var __contentStream_500 = await __response . Content . ReadAsStreamAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
231- __value_500 = await global ::AssemblyAI . Error . FromJsonStreamAsync ( __contentStream_500 , JsonSerializerContext ) . ConfigureAwait ( false ) ;
275+ __exception_500 = __ex ;
232276 }
233277
234278 throw new global ::AssemblyAI . ApiException < global ::AssemblyAI . Error > (
235279 message : __content_500 ?? __response . ReasonPhrase ?? string . Empty ,
280+ innerException : __exception_500 ,
236281 statusCode : __response . StatusCode )
237282 {
238283 ResponseBody = __content_500 ,
@@ -247,17 +292,26 @@ partial void ProcessGetSubtitlesResponseContent(
247292 if ( ( int ) __response . StatusCode == 503 )
248293 {
249294 string ? __content_503 = null ;
250- if ( ReadResponseAsString )
295+ global ::System . Exception ? __exception_503 = null ;
296+ try
251297 {
252- __content_503 = await __response . Content . ReadAsStringAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
298+ if ( ReadResponseAsString )
299+ {
300+ __content_503 = await __response . Content . ReadAsStringAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
301+ }
302+ else
303+ {
304+ var __contentStream_503 = await __response . Content . ReadAsStreamAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
305+ }
253306 }
254- else
307+ catch ( global :: System . Exception __ex )
255308 {
256- var __contentStream_503 = await __response . Content . ReadAsStreamAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
309+ __exception_503 = __ex ;
257310 }
258311
259312 throw new global ::AssemblyAI . ApiException (
260313 message : __content_503 ?? __response . ReasonPhrase ?? string . Empty ,
314+ innerException : __exception_503 ,
261315 statusCode : __response . StatusCode )
262316 {
263317 ResponseBody = __content_503 ,
@@ -271,17 +325,26 @@ partial void ProcessGetSubtitlesResponseContent(
271325 if ( ( int ) __response . StatusCode == 504 )
272326 {
273327 string ? __content_504 = null ;
274- if ( ReadResponseAsString )
328+ global ::System . Exception ? __exception_504 = null ;
329+ try
275330 {
276- __content_504 = await __response . Content . ReadAsStringAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
331+ if ( ReadResponseAsString )
332+ {
333+ __content_504 = await __response . Content . ReadAsStringAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
334+ }
335+ else
336+ {
337+ var __contentStream_504 = await __response . Content . ReadAsStreamAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
338+ }
277339 }
278- else
340+ catch ( global :: System . Exception __ex )
279341 {
280- var __contentStream_504 = await __response . Content . ReadAsStreamAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
342+ __exception_504 = __ex ;
281343 }
282344
283345 throw new global ::AssemblyAI . ApiException (
284346 message : __content_504 ?? __response . ReasonPhrase ?? string . Empty ,
347+ innerException : __exception_504 ,
285348 statusCode : __response . StatusCode )
286349 {
287350 ResponseBody = __content_504 ,
@@ -312,8 +375,10 @@ partial void ProcessGetSubtitlesResponseContent(
312375 try
313376 {
314377 __response . EnsureSuccessStatusCode ( ) ;
378+
379+ return __content ;
315380 }
316- catch ( global ::System . Net . Http . HttpRequestException __ex )
381+ catch ( global ::System . Exception __ex )
317382 {
318383 throw new global ::AssemblyAI . ApiException (
319384 message : __content ?? __response . ReasonPhrase ?? string . Empty ,
@@ -327,16 +392,22 @@ partial void ProcessGetSubtitlesResponseContent(
327392 h => h . Value ) ,
328393 } ;
329394 }
330-
331- return __content ;
332395 }
333396 else
334397 {
335398 try
336399 {
337400 __response . EnsureSuccessStatusCode ( ) ;
401+
402+ var __content = await __response . Content . ReadAsStringAsync (
403+ #if NET5_0_OR_GREATER
404+ cancellationToken
405+ #endif
406+ ) . ConfigureAwait ( false ) ;
407+
408+ return __content ;
338409 }
339- catch ( global ::System . Net . Http . HttpRequestException __ex )
410+ catch ( global ::System . Exception __ex )
340411 {
341412 throw new global ::AssemblyAI . ApiException (
342413 message : __response . ReasonPhrase ?? string . Empty ,
@@ -349,14 +420,6 @@ partial void ProcessGetSubtitlesResponseContent(
349420 h => h . Value ) ,
350421 } ;
351422 }
352-
353- var __content = await __response . Content . ReadAsStringAsync (
354- #if NET5_0_OR_GREATER
355- cancellationToken
356- #endif
357- ) . ConfigureAwait ( false ) ;
358-
359- return __content ;
360423 }
361424 }
362425 }
0 commit comments