@@ -13,15 +13,6 @@ use azure_core::http::{
13
13
response:: Response ,
14
14
BufResponse , ClientOptions , Context , Method ,
15
15
} ;
16
- use azure_core:: {
17
- error:: HttpError ,
18
- http:: {
19
- pager:: PagerState ,
20
- request:: { options:: ContentType , Request } ,
21
- response:: Response ,
22
- ClientOptions , Context , Method , RawResponse ,
23
- } ,
24
- } ;
25
16
use futures:: TryStreamExt ;
26
17
use serde:: de:: DeserializeOwned ;
27
18
use url:: Url ;
@@ -75,7 +66,9 @@ impl CosmosPipeline {
75
66
resource_link : ResourceLink ,
76
67
) -> azure_core:: Result < BufResponse > {
77
68
let ctx = ctx. with_value ( resource_link) ;
78
- self . pipeline . send ( & ctx, request) . await ?. success ( ) . await
69
+ let r = self . pipeline . send ( & ctx, request) . await ?;
70
+ let r = azure_core:: http:: check_success ( r) . await ?;
71
+ Ok ( r)
79
72
}
80
73
81
74
pub async fn send < T > (
@@ -116,7 +109,8 @@ impl CosmosPipeline {
116
109
req. insert_header ( constants:: CONTINUATION , continuation) ;
117
110
}
118
111
119
- let resp = pipeline. send ( & ctx, & mut req) . await ?. success ( ) . await ?;
112
+ let resp = pipeline. send ( & ctx, & mut req) . await ?;
113
+ let resp = azure_core:: http:: check_success ( resp) . await ?;
120
114
let page = FeedPage :: < T > :: from_response ( resp) . await ?;
121
115
122
116
Ok ( page. into ( ) )
@@ -202,39 +196,3 @@ pub(crate) fn create_base_query_request(url: Url, query: &Query) -> azure_core::
202
196
request. set_json ( query) ?;
203
197
Ok ( request)
204
198
}
205
-
206
- trait ResponseExt {
207
- async fn success ( self ) -> azure_core:: Result < Self >
208
- where
209
- Self : Sized ;
210
- }
211
-
212
- impl < T , F > ResponseExt for Response < T , F > {
213
- async fn success ( self ) -> azure_core:: Result < Self > {
214
- if self . status ( ) . is_success ( ) {
215
- Ok ( self )
216
- } else {
217
- RawResponse :: from ( self ) . success ( ) . await . map ( Into :: into)
218
- }
219
- }
220
- }
221
-
222
- impl ResponseExt for RawResponse {
223
- async fn success ( self ) -> azure_core:: Result < Self > {
224
- if self . status ( ) . is_success ( ) {
225
- Ok ( self )
226
- } else {
227
- let http_error = HttpError :: new ( self , Some ( constants:: SUB_STATUS ) ) . await ;
228
- let status = http_error. status ( ) ;
229
- let error_kind = azure_core:: error:: ErrorKind :: http_response (
230
- status,
231
- http_error. error_code ( ) . map ( ToOwned :: to_owned) ,
232
- ) ;
233
- Err ( azure_core:: Error :: full (
234
- error_kind,
235
- http_error,
236
- format ! ( "Request failed with status code: {}" , status) ,
237
- ) )
238
- }
239
- }
240
- }
0 commit comments