core_crypto/mls/conversation/
error.rs1#![expect(missing_docs)]
5
6use crate::ClientId;
7
8pub type Result<T, E = Error> = core::result::Result<T, E>;
9
10#[derive(Debug, thiserror::Error)]
11pub enum Error {
12 #[error("Member with id {_0} doesn't exist")]
13 MemberNotFound(ClientId),
14 #[error(
15 "The tnt message counter has overflowed. You sent 2^32 targeted or transient messages in this epoch. Increment
16 the epoch and try again."
17 )]
18 TntMessageCounterOverflow,
19 #[error("Message rejected by the delivery service. Reason: {reason}")]
21 MessageRejected {
22 reason: String,
24 },
25 #[error("MLS Client was not initialized the right way")]
26 IdentityInitializationError,
27 #[error("MLS group is in an invalid state: {0}")]
28 MlsGroupInvalidState(&'static str),
29 #[error("MLS message is in an invalid state: {0}")]
30 MlsMessageInvalidState(&'static str),
31 #[error("The group lacks an ExternalSender extension whereas it should have at least one")]
32 MissingExternalSenderExtension,
33 #[error("unexpectedly failed to retrieve group info")]
34 MissingGroupInfo,
35 #[error("Couldn't find pending commit")]
36 PendingCommitNotFound,
37 #[error(
38 "Happens when a client creates a commit, sends it to the DS which accepts it but then client \
39 clears this pending commit and creates another commit. This is triggered when the client tries to decrypt the original commit.\
40 This means something is very wrong in the client's code and has to be fixed immediately"
41 )]
42 ClearingPendingCommitError,
43 #[error("Tried to decrypt a commit created by self which is likely to have been replayed by the DS")]
44 SelfCommitIgnored,
45 #[error("caller error: {0}")]
46 CallerError(&'static str),
47 #[error(
52 "Although this Welcome seems valid, the local KeyPackage it references has already been deleted locally. Join this group with an external commit"
53 )]
54 OrphanWelcome,
55 #[error("Operation couldn't be performed due to duplicate signature for clients: {affected_clients:?}")]
56 DuplicateSignature {
57 affected_clients: Vec<(crate::ClientId, crate::ClientId)>,
58 },
59 #[error("this conversation has been invalidated due to its `Session` reference dropping")]
60 SessionDropped,
61 #[error(transparent)]
62 Tls(#[from] crate::TlsCodecError),
63 #[error(transparent)]
64 OpenMls(#[from] crate::OpenMlsError),
65 #[error(transparent)]
66 Keystore(#[from] crate::KeystoreError),
67 #[error(transparent)]
68 Recursive(#[from] crate::RecursiveError),
69}
70
71impl Error {
72 pub(super) fn savepoint(
73 context: &'static str,
74 ) -> Box<dyn FnOnce(core_crypto_keystore::CryptoKeystoreError) -> Self> {
75 Box::new(move |err| crate::KeystoreError::wrap(context)(err).into())
76 }
77}