return proper error if we fail to convert to canonical JSON

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-01-17 19:58:10 -05:00 committed by June
parent 3d6b499b88
commit c83acabfb0

View file

@ -814,8 +814,10 @@ impl Service {
}
// Hash and sign
let mut pdu_json =
utils::to_canonical_object(&pdu).expect("event is valid, we just created it");
let mut pdu_json = utils::to_canonical_object(&pdu).map_err(|e| {
error!("Failed to convert PDU {:?} to canonical JSON: {}", &pdu, e);
Error::bad_database("Failed to convert PDU to canonical JSON.")
})?;
pdu_json.remove("event_id");