diff --git a/src/utils/error.rs b/src/utils/error.rs index 980373b9..833c72b8 100644 --- a/src/utils/error.rs +++ b/src/utils/error.rs @@ -99,15 +99,6 @@ impl Error { return Ra(UiaaResponse::AuthResponse(uiaainfo.clone())); } - if let Self::Federation(origin, error) = self { - let mut error = error.clone(); - error.body = ErrorBody::Standard { - kind: Unknown, - message: format!("Answer from {origin}: {error}"), - }; - return Ra(UiaaResponse::MatrixError(error)); - } - let message = format!("{}", self.display_with_sources(" -> ")); let (kind, status_code) = match self { @@ -138,6 +129,11 @@ impl Error { _ => StatusCode::BAD_REQUEST, }, ), + // Propagate the status code and error code from the remote response + Self::Federation(_, error) => ( + error.error_kind().cloned().unwrap_or(Unknown), + error.status_code, + ), Self::UnsupportedRoomVersion(_) => ( ErrorKind::UnsupportedRoomVersion, StatusCode::INTERNAL_SERVER_ERROR,