api: Rename FromHttpResponseError::{Http => Server}

This commit is contained in:
Jonas Platte 2022-03-21 19:36:27 +01:00 committed by Jonas Platte
parent 54f9db8ccc
commit ffd7625a17
2 changed files with 4 additions and 4 deletions

View File

@ -131,21 +131,21 @@ pub enum FromHttpResponseError<E> {
Deserialization(DeserializationError), Deserialization(DeserializationError),
/// The server returned a non-success status /// The server returned a non-success status
Http(ServerError<E>), Server(ServerError<E>),
} }
impl<E: fmt::Display> fmt::Display for FromHttpResponseError<E> { impl<E: fmt::Display> fmt::Display for FromHttpResponseError<E> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::Deserialization(err) => write!(f, "deserialization failed: {}", err), Self::Deserialization(err) => write!(f, "deserialization failed: {}", err),
Self::Http(err) => write!(f, "the server returned an error: {}", err), Self::Server(err) => write!(f, "the server returned an error: {}", err),
} }
} }
} }
impl<E> From<ServerError<E>> for FromHttpResponseError<E> { impl<E> From<ServerError<E>> for FromHttpResponseError<E> {
fn from(err: ServerError<E>) -> Self { fn from(err: ServerError<E>) -> Self {
Self::Http(err) Self::Server(err)
} }
} }

View File

@ -120,7 +120,7 @@ impl IncomingResponse for Response {
if http_response.status().as_u16() < 400 { if http_response.status().as_u16() < 400 {
Ok(Response) Ok(Response)
} else { } else {
Err(FromHttpResponseError::Http(ServerError::Known( Err(FromHttpResponseError::Server(ServerError::Known(
<MatrixError as EndpointError>::try_from_http_response(http_response)?, <MatrixError as EndpointError>::try_from_http_response(http_response)?,
))) )))
} }