Skip to main content

de_mls/core/
error.rs

1//! Core library errors.
2
3use crate::mls_crypto;
4
5#[derive(Debug, thiserror::Error)]
6pub enum CoreError {
7    /// MLS error (covers service, wire-format, and storage variants).
8    #[error("MLS error: {0}")]
9    Mls(#[from] mls_crypto::MlsError),
10
11    #[error("Consensus error: {0}")]
12    ConsensusError(#[from] hashgraph_like_consensus::error::ConsensusError),
13
14    #[error("System time error: {0}")]
15    SystemTimeError(#[from] std::time::SystemTimeError),
16
17    /// Message encoding/decoding error.
18    #[error("Message error: {0}")]
19    MessageError(#[from] prost::DecodeError),
20
21    /// MLS group is not initialized for this conversation.
22    #[error("MLS group not initialized")]
23    MlsGroupNotInitialized,
24
25    /// Caller is not a steward of this conversation.
26    #[error("caller is not a steward")]
27    NotASteward,
28
29    /// No proposals available for the requested operation.
30    #[error("No proposals available")]
31    NoProposals,
32
33    #[error("Invalid conversation update request")]
34    InvalidConversationUpdateRequest,
35
36    #[error("Invalid subtopic: {0}")]
37    InvalidSubtopic(String),
38
39    #[error("Empty members list")]
40    EmptyMembersList,
41
42    #[error("Invalid config size")]
43    InvalidConfigSize,
44
45    /// Governance proposals (emergency criteria, steward election) slipped into
46    /// the approved queue — `apply_consensus_result` should have removed them
47    /// before `create_commit_candidate` ran.
48    #[error(
49        "Non-MLS proposals found in approved queue (ids: {proposal_ids:?}). \
50         They should have been removed by apply_consensus_result."
51    )]
52    UnexpectedNonMlsProposals { proposal_ids: Vec<u32> },
53}