propagate error code from federation response errors

Previously we were propagating the status code, but always returning
M_UNKNOWN regardless of the remote error code. This seems kinda
pointless, so just propagate both. We can also stop special-casing the
message now that the display impl is reasonable.
This commit is contained in:
Olivia Lee 2024-12-14 16:47:46 -08:00
parent 45be146c14
commit 165ff0b50c
No known key found for this signature in database
GPG key ID: 54D568A15B9CD1F9

View file

@ -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,