refactor some additional errors
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
f51d4237c7
commit
2e3e14b045
13 changed files with 127 additions and 148 deletions
|
@ -86,13 +86,13 @@ pub enum Error {
|
|||
// conduwuit
|
||||
#[error("Arithmetic operation failed: {0}")]
|
||||
Arithmetic(Cow<'static, str>),
|
||||
#[error("{0}")]
|
||||
BadServerResponse(Cow<'static, str>),
|
||||
#[error("There was a problem with the '{0}' directive in your configuration: {1}")]
|
||||
Config(&'static str, Cow<'static, str>),
|
||||
#[error("{0}")]
|
||||
Database(Cow<'static, str>),
|
||||
#[error("{0}")]
|
||||
BadServerResponse(&'static str),
|
||||
#[error("{0}")]
|
||||
Conflict(&'static str), // This is only needed for when a room alias already exists
|
||||
|
||||
// unique / untyped
|
||||
|
|
|
@ -23,7 +23,7 @@ use serde_json::{
|
|||
value::{to_raw_value, RawValue as RawJsonValue},
|
||||
};
|
||||
|
||||
use crate::{warn, Error};
|
||||
use crate::{err, warn, Error};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct ExtractRedactedBecause {
|
||||
|
@ -396,10 +396,8 @@ impl Ord for PduEvent {
|
|||
pub fn gen_event_id_canonical_json(
|
||||
pdu: &RawJsonValue, room_version_id: &RoomVersionId,
|
||||
) -> crate::Result<(OwnedEventId, CanonicalJsonObject)> {
|
||||
let value: CanonicalJsonObject = serde_json::from_str(pdu.get()).map_err(|e| {
|
||||
warn!("Error parsing incoming event {:?}: {:?}", pdu, e);
|
||||
Error::BadServerResponse("Invalid PDU in server response")
|
||||
})?;
|
||||
let value: CanonicalJsonObject = serde_json::from_str(pdu.get())
|
||||
.map_err(|e| err!(BadServerResponse(warn!("Error parsing incoming event: {e:?}"))))?;
|
||||
|
||||
let event_id = format!(
|
||||
"${}",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue