show source chain in error response message

Error messages in logs should generally be similar to the messages in
the response body now. There's a bit of a concern with the source chain
leaking sensitive information, but the errors that had a source were
generally already logging the second error in the chain in their own
Display impl, so if this is a problem it's unlikely to be a regression.
This commit is contained in:
Olivia Lee 2024-12-14 02:23:46 -08:00
parent a3448b5c84
commit a2628357fd
No known key found for this signature in database
GPG key ID: 54D568A15B9CD1F9

View file

@ -9,6 +9,7 @@ use ruma::{
OwnedServerName, OwnedServerName,
}; };
use thiserror::Error; use thiserror::Error;
use wee_woo::ErrorExt;
use crate::{observability::prelude::*, Ra}; use crate::{observability::prelude::*, Ra};
@ -117,7 +118,7 @@ impl Error {
return Ra(UiaaResponse::MatrixError(error)); return Ra(UiaaResponse::MatrixError(error));
} }
let message = format!("{self}"); let message = format!("{}", self.display_with_sources(" -> "));
let (kind, status_code) = match self { let (kind, status_code) = match self {
Self::BadRequest(kind, _) => ( Self::BadRequest(kind, _) => (