1use core_crypto::InnermostErrorMessage as _;
23#[derive(Debug, thiserror::Error)]
4#[cfg_attr(target_family = "wasm", derive(strum::AsRefStr))]
5#[cfg_attr(not(target_family = "wasm"), derive(uniffi::Error))]
6pub enum MlsError {
7#[error("Conversation already exists")]
8ConversationAlreadyExists(core_crypto::prelude::ConversationId),
9#[error("We already decrypted this message once")]
10DuplicateMessage,
11#[error("Incoming message is for a future epoch. We will buffer it until the commit for that epoch arrives")]
12BufferedFutureMessage,
13#[error("Incoming message is from an epoch too far in the future to buffer.")]
14WrongEpoch,
15#[error(
16"Incoming message is a commit for which we have not yet received all the proposals. Buffering until all proposals have arrived."
17)]
18BufferedCommit,
19#[error("The epoch in which message was encrypted is older than allowed")]
20MessageEpochTooOld,
21#[error("Tried to decrypt a commit created by self which is likely to have been replayed by the DS")]
22SelfCommitIgnored,
23#[error(
24"You tried to join with an external commit but did not merge it yet. We will reapply this message for you when you merge your external commit"
25)]
26UnmergedPendingGroup,
27#[error("The received proposal is deemed stale and is from an older epoch.")]
28StaleProposal,
29#[error("The received commit is deemed stale and is from an older epoch.")]
30StaleCommit,
31/// This happens when the DS cannot flag KeyPackages as claimed or not. It this scenario, a client
32 /// requests their old KeyPackages to be deleted but one has already been claimed by another client to create a Welcome.
33 /// In that case the only solution is that the client receiving such a Welcome tries to join the group
34 /// with an External Commit instead
35#[error(
36"Although this Welcome seems valid, the local KeyPackage it references has already been deleted locally. Join this group with an external commit"
37)]
38OrphanWelcome,
39/// Message rejected by the delivery service
40#[error("Message rejected by the delivery service. Reason: {reason}")]
41MessageRejected {
42/// Why was the message rejected by the delivery service?
43reason: String,
44 },
45#[error("{0}")]
46Other(String),
47}
4849impl From<core_crypto::MlsError> for MlsError {
50#[inline]
51fn from(e: core_crypto::MlsError) -> Self {
52Self::Other(e.innermost_error_message())
53 }
54}