openmls/group/public_group/
errors.rs

1use thiserror::Error;
2
3use crate::{
4    error::LibraryError,
5    extensions::errors::InvalidExtensionError,
6    treesync::errors::{LeafNodeValidationError, TreeSyncFromNodesError},
7};
8
9/// Public group creation from external error.
10#[derive(Error, Debug, PartialEq, Clone)]
11pub enum CreationFromExternalError<StorageError> {
12    /// See [`LibraryError`] for more details.
13    #[error(transparent)]
14    LibraryError(#[from] LibraryError),
15    /// This error indicates the public tree is invalid. See [`TreeSyncFromNodesError`] for more details.
16    #[error(transparent)]
17    TreeSyncError(#[from] TreeSyncFromNodesError),
18    /// Sender not found in tree.
19    #[error("Sender not found in tree.")]
20    UnknownSender,
21    /// The signature on the GroupInfo is not valid.
22    #[error("The signature on the GroupInfo is not valid.")]
23    InvalidGroupInfoSignature,
24    /// The computed tree hash does not match the one in the GroupInfo.
25    #[error("The computed tree hash does not match the one in the GroupInfo.")]
26    TreeHashMismatch,
27    /// We don't support the version of the group we are trying to join.
28    #[error("We don't support the version of the group we are trying to join.")]
29    UnsupportedMlsVersion,
30    /// See [`LeafNodeValidationError`]
31    #[error(transparent)]
32    LeafNodeValidation(#[from] LeafNodeValidationError),
33    /// Error writing to storage.
34    #[error("Error writing to storage: {0}")]
35    WriteToStorageError(StorageError),
36    /// A parent node has an unmerged leaf that is not a descendant of the node.
37    #[error("A parent node has an unmerged leaf that is not a descendant of the node")]
38    UnmergedLeafNotADescendant,
39    /// Found a path from a parent with an unmerged leaf to the leaf with nodes that do not have that as a leaf  
40    #[error("Found a path from a parent with an unmerged leaf to the leaf with nodes that do not have that as a leaf")]
41    IntermediateNodeMissingUnmergedLeaf,
42    /// The ratchet tree contains duplcate encryption keys
43    #[error("The ratchet tree contains duplcate encryption keys")]
44    DuplicateEncryptionKey,
45}
46
47/// Public group builder error.
48#[derive(Error, Debug, PartialEq, Clone)]
49pub enum PublicGroupBuildError {
50    /// See [`LibraryError`] for more details.
51    #[error(transparent)]
52    LibraryError(#[from] LibraryError),
53    /// Invalid extensions set in configuration
54    #[error("Invalid extensions set in configuration")]
55    InvalidExtensions(#[from] InvalidExtensionError),
56}