use thiserror::Error;
use crate::{
error::LibraryError,
extensions::errors::InvalidExtensionError,
group::{
errors::{
CreateAddProposalError, CreateCommitError, MergeCommitError, StageCommitError,
ValidationError,
},
CommitBuilderStageError, CreateGroupContextExtProposalError,
},
schedule::errors::PskError,
treesync::{
errors::{LeafNodeValidationError, PublicTreeError},
node::leaf_node::LeafNodeUpdateError,
},
};
#[derive(Error, Debug, PartialEq, Clone)]
pub enum NewGroupError<StorageError> {
#[error(transparent)]
LibraryError(#[from] LibraryError),
#[error("No matching KeyPackage was found in the key store.")]
NoMatchingKeyPackage,
#[error("Error accessing the storage.")]
StorageError(StorageError),
#[error("Unsupported proposal type in required capabilities.")]
UnsupportedProposalType,
#[error("Unsupported extension type in required capabilities.")]
UnsupportedExtensionType,
#[error("Invalid extensions set in configuration")]
InvalidExtensions(#[from] InvalidExtensionError),
}
#[derive(Error, Debug, PartialEq, Eq, Clone)]
pub enum EmptyInputError {
#[error("An empty list of KeyPackages was provided.")]
AddMembers,
#[error("An empty list of KeyPackage references was provided.")]
RemoveMembers,
}
#[derive(Error, Debug, PartialEq, Clone)]
pub enum MlsGroupStateError {
#[error(transparent)]
LibraryError(#[from] LibraryError),
#[error("Tried to use a group after being evicted from it.")]
UseAfterEviction,
#[error("Can't create message because a pending proposal exists.")]
PendingProposal,
#[error("Can't execute operation because a pending commit exists.")]
PendingCommit,
#[error("Can't execute operation because there is no pending commit")]
NoPendingCommit,
#[error("Requested pending proposal hasn't been found in local pending proposals.")]
PendingProposalNotFound,
}
#[derive(Error, Debug, PartialEq, Clone)]
pub enum MergePendingCommitError<StorageError> {
#[error(transparent)]
MlsGroupStateError(#[from] MlsGroupStateError),
#[error(transparent)]
MergeCommitError(#[from] MergeCommitError<StorageError>),
}
#[derive(Error, Debug, PartialEq, Clone)]
pub enum ProcessMessageError {
#[error(transparent)]
LibraryError(#[from] LibraryError),
#[error("The message's wire format is incompatible with the group's wire format policy.")]
IncompatibleWireFormat,
#[error(transparent)]
ValidationError(#[from] ValidationError),
#[error(transparent)]
GroupStateError(#[from] MlsGroupStateError),
#[error(transparent)]
InvalidCommit(#[from] StageCommitError),
#[error("External application messages are not permitted.")]
UnauthorizedExternalApplicationMessage,
#[error("The proposal is invalid for the Sender of type External")]
UnsupportedProposalType,
}
#[derive(Error, Debug, PartialEq, Clone)]
pub enum CreateMessageError {
#[error(transparent)]
LibraryError(#[from] LibraryError),
#[error(transparent)]
GroupStateError(#[from] MlsGroupStateError),
}
#[derive(Error, Debug, PartialEq, Clone)]
pub enum AddMembersError<StorageError> {
#[error(transparent)]
LibraryError(#[from] LibraryError),
#[error(transparent)]
EmptyInput(#[from] EmptyInputError),
#[error(transparent)]
CreateCommitError(#[from] CreateCommitError),
#[error(transparent)]
CommitBuilderStageError(#[from] CommitBuilderStageError<StorageError>),
#[error(transparent)]
GroupStateError(#[from] MlsGroupStateError),
#[error("Error writing to storage")]
StorageError(StorageError),
}
#[derive(Error, Debug, PartialEq, Clone)]
pub enum ProposeAddMemberError<StorageError> {
#[error(transparent)]
LibraryError(#[from] LibraryError),
#[error("The new member does not support all required extensions.")]
UnsupportedExtensions,
#[error(transparent)]
GroupStateError(#[from] MlsGroupStateError),
#[error(transparent)]
LeafNodeValidation(#[from] LeafNodeValidationError),
#[error("Error writing to storage: {0}")]
StorageError(StorageError),
}
#[derive(Error, Debug, PartialEq, Clone)]
pub enum ProposeRemoveMemberError<StorageError> {
#[error(transparent)]
LibraryError(#[from] LibraryError),
#[error(transparent)]
GroupStateError(#[from] MlsGroupStateError),
#[error("The member that should be removed can not be found.")]
UnknownMember,
#[error("Error writing to storage: {0}")]
StorageError(StorageError),
}
#[derive(Error, Debug, PartialEq, Clone)]
pub enum RemoveMembersError<StorageError> {
#[error(transparent)]
LibraryError(#[from] LibraryError),
#[error(transparent)]
EmptyInput(#[from] EmptyInputError),
#[error(transparent)]
CreateCommitError(#[from] CreateCommitError),
#[error(transparent)]
CommitBuilderStageError(#[from] CommitBuilderStageError<StorageError>),
#[error(transparent)]
GroupStateError(#[from] MlsGroupStateError),
#[error("The member that should be removed can not be found.")]
UnknownMember,
#[error("Error writing to storage: {0}")]
StorageError(StorageError),
}
#[derive(Error, Debug, PartialEq, Clone)]
pub enum LeaveGroupError<StorageError> {
#[error(transparent)]
LibraryError(#[from] LibraryError),
#[error(transparent)]
GroupStateError(#[from] MlsGroupStateError),
#[error("An error ocurred while writing to storage")]
StorageError(StorageError),
#[error("SelfRemove not allowed with pure ciphertext outgoing wire format policy.")]
CannotSelfRemoveWithPureCiphertext,
}
#[derive(Error, Debug, PartialEq, Clone)]
pub enum SelfUpdateError<StorageError> {
#[error(transparent)]
LibraryError(#[from] LibraryError),
#[error(transparent)]
CreateCommitError(#[from] CreateCommitError),
#[error(transparent)]
CommitBuilderStageError(#[from] CommitBuilderStageError<StorageError>),
#[error(transparent)]
GroupStateError(#[from] MlsGroupStateError),
#[error("Error accessing the storage.")]
StorageError(StorageError),
}
#[derive(Error, Debug, PartialEq, Clone)]
pub enum ProposeSelfUpdateError<StorageError> {
#[error(transparent)]
LibraryError(#[from] LibraryError),
#[error(transparent)]
GroupStateError(#[from] MlsGroupStateError),
#[error("Error accessing storage.")]
StorageError(StorageError),
#[error(transparent)]
PublicTreeError(#[from] PublicTreeError),
#[error(transparent)]
LeafNodeUpdateError(#[from] LeafNodeUpdateError<StorageError>),
}
#[derive(Error, Debug, PartialEq, Clone)]
pub enum CommitToPendingProposalsError<StorageError> {
#[error(transparent)]
LibraryError(#[from] LibraryError),
#[error(transparent)]
CreateCommitError(#[from] CreateCommitError),
#[error(transparent)]
CommitBuilderStageError(#[from] CommitBuilderStageError<StorageError>),
#[error(transparent)]
GroupStateError(#[from] MlsGroupStateError),
#[error("Error writing to storage: {0}")]
StorageError(StorageError),
}
#[derive(Error, Debug, PartialEq, Clone)]
pub enum ExportGroupInfoError {
#[error(transparent)]
LibraryError(#[from] LibraryError),
#[error(transparent)]
GroupStateError(#[from] MlsGroupStateError),
}
#[derive(Error, Debug, PartialEq, Clone)]
pub enum ExportSecretError {
#[error(transparent)]
LibraryError(#[from] LibraryError),
#[error("The requested key length is too long.")]
KeyLengthTooLong,
#[error(transparent)]
GroupStateError(#[from] MlsGroupStateError),
}
#[derive(Error, Debug, PartialEq, Clone)]
pub enum ProposePskError {
#[error(transparent)]
Psk(#[from] PskError),
#[error(transparent)]
GroupStateError(#[from] MlsGroupStateError),
#[error(transparent)]
LibraryError(#[from] LibraryError),
}
#[derive(Error, Debug, PartialEq, Clone)]
pub enum ProposalError<StorageError> {
#[error(transparent)]
LibraryError(#[from] LibraryError),
#[error(transparent)]
ProposeAddMemberError(#[from] ProposeAddMemberError<StorageError>),
#[error(transparent)]
CreateAddProposalError(#[from] CreateAddProposalError),
#[error(transparent)]
ProposeSelfUpdateError(#[from] ProposeSelfUpdateError<StorageError>),
#[error(transparent)]
ProposeRemoveMemberError(#[from] ProposeRemoveMemberError<StorageError>),
#[error(transparent)]
GroupStateError(#[from] MlsGroupStateError),
#[error(transparent)]
ValidationError(#[from] ValidationError),
#[error(transparent)]
CreateGroupContextExtProposalError(#[from] CreateGroupContextExtProposalError<StorageError>),
#[error("error writing proposal to storage")]
StorageError(StorageError),
}
#[derive(Error, Debug, PartialEq, Clone)]
pub enum RemoveProposalError<StorageError> {
#[error("Couldn't find the proposal for the given `ProposalRef`")]
ProposalNotFound,
#[error("error writing proposal to storage")]
Storage(StorageError),
}