core_crypto/mls/session/
error.rs1#![allow(missing_docs)]
5
6pub(crate) type Result<T, E = Error> = core::result::Result<T, E>;
7
8#[derive(Debug, thiserror::Error)]
9pub enum Error {
10 #[error("Supplied user id was not valid")]
11 InvalidUserId,
12 #[error("X509 certificate bundle set was empty")]
13 NoX509CertificateBundle,
14 #[error("Tried to insert an already existing CredentialBundle")]
15 CredentialBundleConflict,
16 #[error("A MLS operation was requested but MLS hasn't been initialized on this instance")]
17 MlsNotInitialized,
18 #[error("A Credential of type {0:?} was not found locally which is very likely an implementation error")]
19 CredentialNotFound(crate::prelude::MlsCredentialType),
20 #[error("supplied signature scheme was not valid")]
21 InvalidSignatureScheme,
22 #[error("The provided client signature has not been found in the keystore")]
24 ClientSignatureNotFound,
25 #[error("Client was unexpectedly ready")]
29 UnexpectedlyReady,
30 #[error("The keystore already contains a stored identity. Cannot create a new one!")]
31 IdentityAlreadyPresent,
32 #[error("The supplied credential does not match the id or signature schemes provided")]
33 WrongCredential,
34 #[error("An EpochObserver has already been registered; reregistration is not possible")]
35 EpochObserverAlreadyExists,
36 #[error("Serializing {item} for TLS")]
37 TlsSerialize {
38 item: &'static str,
39 #[source]
40 source: tls_codec::Error,
41 },
42 #[error("Deserializing {item} for TLS")]
43 TlsDeserialize {
44 item: &'static str,
45 #[source]
46 source: tls_codec::Error,
47 },
48 #[error(transparent)]
49 Mls(#[from] crate::MlsError),
50 #[error(transparent)]
51 Keystore(#[from] crate::KeystoreError),
52 #[error("{0}")]
53 Leaf(#[from] crate::LeafError),
54 #[error(transparent)]
55 Recursive(#[from] crate::RecursiveError),
56}
57
58impl Error {
59 pub fn tls_serialize(item: &'static str) -> impl FnOnce(tls_codec::Error) -> Self {
60 move |source| Self::TlsSerialize { item, source }
61 }
62
63 pub fn tls_deserialize(item: &'static str) -> impl FnOnce(tls_codec::Error) -> Self {
64 move |source| Self::TlsDeserialize { item, source }
65 }
66}