core_crypto/e2e_identity/
error.rs1#![allow(missing_docs)]
5
6pub type Result<T, E = Error> = core::result::Result<T, E>;
7
8#[derive(Debug, thiserror::Error)]
9pub enum Error {
10 #[error("Incorrect usage of this API")]
11 ImplementationError,
12 #[error("Not yet supported")]
13 NotYetSupported,
14 #[error("Enrollment methods are called out of order: {0}")]
15 OutOfOrderEnrollment(&'static str),
16 #[error("Invalid OIDC RefreshToken supplied")]
17 InvalidRefreshToken,
18 #[error("The encountered ClientId does not match Wire's definition")]
19 InvalidClientId,
20 #[error("This function accepts a list of IDs as a parameter, but that list was empty")]
21 EmptyInputIdList,
22 #[error(transparent)]
23 IdentityError(#[from] wire_e2e_identity::prelude::E2eIdentityError),
24 #[error(transparent)]
25 X509Error(#[from] wire_e2e_identity::prelude::x509::RustyX509CheckError),
26 #[error(transparent)]
27 UrlError(#[from] url::ParseError),
28 #[error(transparent)]
29 JsonError(#[from] serde_json::Error),
30 #[error(transparent)]
31 X509CertDerError(#[from] x509_cert::der::Error),
32 #[error("Serializing key package for TLS")]
33 TlsSerializingKeyPackage(#[from] tls_codec::Error),
34 #[error("{context}: {upstream}")]
35 CertificateValidation {
36 context: &'static str,
37 upstream: String,
41 },
42 #[error(transparent)]
43 Mls(#[from] crate::MlsError),
44 #[error(transparent)]
45 Keystore(#[from] crate::KeystoreError),
46 #[error("{0}")]
47 Leaf(#[from] crate::LeafError),
48 #[error(transparent)]
49 Recursive(#[from] crate::RecursiveError),
50}
51
52impl Error {
53 pub(crate) fn certificate_validation<E>(context: &'static str) -> impl FnOnce(E) -> Self
54 where
55 E: std::fmt::Debug,
56 {
57 move |source| Self::CertificateValidation {
58 context,
59 upstream: format!("{source:?}"),
60 }
61 }
62}