#[derive(Debug, thiserror::Error)]
pub enum MessengerError {
#[error("invalid {kind} {value:?}: {reason}")]
InvalidId {
kind: &'static str,
value: String,
reason: String,
},
#[error("failed to decode wire JSON: {0}")]
WireDecode(#[from] serde_json::Error),
#[error("HTTP {status} {errcode}: {error}")]
Http {
status: u16,
errcode: String,
error: String,
},
#[error("crypto: {0}")]
Crypto(String),
#[error("store: {0}")]
Store(#[from] crate::store::StoreError),
#[error(
"outgoing requests are blocked: a state mutation they depend on is not yet flushed and acknowledged"
)]
FlushPending,
#[error("cannot edit {event_id}: not sent by this account, or unknown")]
EditNotOwned {
event_id: crate::ids::EventId,
},
#[error("intent refused: {0}")]
IntentRefused(String),
}
impl From<crate::canonical_json::CanonicalJsonError> for MessengerError {
fn from(err: crate::canonical_json::CanonicalJsonError) -> Self {
MessengerError::Crypto(format!("canonical JSON: {err}"))
}
}