@@ -81,23 +81,95 @@ partial void ProcessDeleteResponseResponse(
8181 ProcessDeleteResponseResponse (
8282 httpClient : HttpClient ,
8383 httpResponseMessage : __response ) ;
84- try
84+ // Not Found
85+ if ( ( int ) __response . StatusCode == 404 )
8586 {
86- __response . EnsureSuccessStatusCode ( ) ;
87- }
88- catch ( global ::System . Net . Http . HttpRequestException __ex )
89- {
90- throw new global ::tryAGI . OpenAI . ApiException (
91- message : __response . ReasonPhrase ?? string . Empty ,
92- innerException : __ex ,
87+ string ? __content_404 = null ;
88+ global ::tryAGI . OpenAI . Error ? __value_404 = null ;
89+ if ( ReadResponseAsString )
90+ {
91+ __content_404 = await __response . Content . ReadAsStringAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
92+ __value_404 = global ::tryAGI . OpenAI . Error . FromJson ( __content_404 , JsonSerializerContext ) ;
93+ }
94+ else
95+ {
96+ var __contentStream_404 = await __response . Content . ReadAsStreamAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
97+ __value_404 = await global ::tryAGI . OpenAI . Error . FromJsonStreamAsync ( __contentStream_404 , JsonSerializerContext ) . ConfigureAwait ( false ) ;
98+ }
99+
100+ throw new global ::tryAGI . OpenAI . ApiException < global ::tryAGI . OpenAI . Error > (
101+ message : __content_404 ?? __response . ReasonPhrase ?? string . Empty ,
93102 statusCode : __response . StatusCode )
94103 {
104+ ResponseBody = __content_404 ,
105+ ResponseObject = __value_404 ,
95106 ResponseHeaders = global ::System . Linq . Enumerable . ToDictionary (
96107 __response . Headers ,
97108 h => h . Key ,
98109 h => h . Value ) ,
99110 } ;
100111 }
112+
113+ if ( ReadResponseAsString )
114+ {
115+ var __content = await __response . Content . ReadAsStringAsync (
116+ #if NET5_0_OR_GREATER
117+ cancellationToken
118+ #endif
119+ ) . ConfigureAwait ( false ) ;
120+
121+ ProcessResponseContent (
122+ client : HttpClient ,
123+ response : __response ,
124+ content : ref __content ) ;
125+
126+ try
127+ {
128+ __response . EnsureSuccessStatusCode ( ) ;
129+ }
130+ catch ( global ::System . Net . Http . HttpRequestException __ex )
131+ {
132+ throw new global ::tryAGI . OpenAI . ApiException (
133+ message : __content ?? __response . ReasonPhrase ?? string . Empty ,
134+ innerException : __ex ,
135+ statusCode : __response . StatusCode )
136+ {
137+ ResponseBody = __content ,
138+ ResponseHeaders = global ::System . Linq . Enumerable . ToDictionary (
139+ __response . Headers ,
140+ h => h . Key ,
141+ h => h . Value ) ,
142+ } ;
143+ }
144+
145+ }
146+ else
147+ {
148+ try
149+ {
150+ __response . EnsureSuccessStatusCode ( ) ;
151+ }
152+ catch ( global ::System . Net . Http . HttpRequestException __ex )
153+ {
154+ throw new global ::tryAGI . OpenAI . ApiException (
155+ message : __response . ReasonPhrase ?? string . Empty ,
156+ innerException : __ex ,
157+ statusCode : __response . StatusCode )
158+ {
159+ ResponseHeaders = global ::System . Linq . Enumerable . ToDictionary (
160+ __response . Headers ,
161+ h => h . Key ,
162+ h => h . Value ) ,
163+ } ;
164+ }
165+
166+ using var __content = await __response . Content . ReadAsStreamAsync (
167+ #if NET5_0_OR_GREATER
168+ cancellationToken
169+ #endif
170+ ) . ConfigureAwait ( false ) ;
171+
172+ }
101173 }
102174 }
103175}
0 commit comments