Skip to content

Commit 3691354

Browse files
authored
revert change to Response<T, F>
1 parent 79c3bc5 commit 3691354

File tree

1 file changed

+2
-26
lines changed

1 file changed

+2
-26
lines changed

sdk/typespec/typespec_client_core/src/http/response.rs

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,12 @@
33

44
//! HTTP responses.
55
6-
use crate::{
7-
error::HttpError,
8-
http::{headers::Headers, DeserializeWith, Format, JsonFormat, StatusCode},
9-
};
6+
use crate::http::{headers::Headers, DeserializeWith, Format, JsonFormat, StatusCode};
107
use bytes::Bytes;
118
use futures::{Stream, StreamExt};
129
use serde::de::DeserializeOwned;
1310
use std::{fmt, marker::PhantomData, pin::Pin};
14-
use typespec::{
15-
error::{ErrorKind, ResultExt},
16-
Error,
17-
};
11+
use typespec::error::{ErrorKind, ResultExt};
1812

1913
#[cfg(not(target_arch = "wasm32"))]
2014
pub type PinnedStream = Pin<Box<dyn Stream<Item = crate::Result<Bytes>> + Send>>;
@@ -83,24 +77,6 @@ pub struct Response<T, F = JsonFormat> {
8377
}
8478

8579
impl<T, F> Response<T, F> {
86-
pub async fn success(self) -> crate::Result<Self> {
87-
let status = self.status();
88-
if status.is_success() {
89-
Ok(self)
90-
} else {
91-
let http_error = HttpError::new(self.raw).await;
92-
let error_kind = ErrorKind::http_response(
93-
status,
94-
http_error.error_code().map(std::borrow::ToOwned::to_owned),
95-
);
96-
Err(Error::full(
97-
error_kind,
98-
http_error,
99-
format!("server returned an error response: {status}"),
100-
))
101-
}
102-
}
103-
10480
/// Get the status code from the response.
10581
pub fn status(&self) -> StatusCode {
10682
self.raw.status()

0 commit comments

Comments
 (0)