1//! End to end identity errors
23// We allow missing documentation in the error module because the types are generally self-descriptive.
4#![allow(missing_docs)]
56pub type Result<T, E = Error> = core::result::Result<T, E>;
78#[derive(Debug, thiserror::Error)]
9pub enum Error {
10#[error("Incorrect usage of this API")]
11ImplementationError,
12#[error("Not yet supported")]
13NotYetSupported,
14#[error("Enrollment methods are called out of order: {0}")]
15OutOfOrderEnrollment(&'static str),
16#[error("Invalid OIDC RefreshToken supplied")]
17InvalidRefreshToken,
18#[error("The encountered ClientId does not match Wire's definition")]
19InvalidClientId,
20#[error("This function accepts a list of IDs as a parameter, but that list was empty")]
21EmptyInputIdList,
22#[error(transparent)]
23IdentityError(#[from] wire_e2e_identity::prelude::E2eIdentityError),
24#[error(transparent)]
25X509Error(#[from] wire_e2e_identity::prelude::x509::RustyX509CheckError),
26#[error(transparent)]
27UrlError(#[from] url::ParseError),
28#[error(transparent)]
29JsonError(#[from] serde_json::Error),
30#[error(transparent)]
31X509CertDerError(#[from] x509_cert::der::Error),
32#[error("Serializing key package for TLS")]
33TlsSerializingKeyPackage(#[from] tls_codec::Error),
34#[error("{context}: {upstream}")]
35CertificateValidation {
36 context: &'static str,
37// We the programmer know that this error type comes from the `certval` crate,
38 // but that is not in scope at this point and doesn't implement `std::error::Error`,
39 // so ¯\_(ツ)_/¯
40upstream: String,
41 },
42#[error(transparent)]
43Mls(#[from] crate::MlsError),
44#[error(transparent)]
45Keystore(#[from] crate::KeystoreError),
46#[error("{0}")]
47Leaf(#[from] crate::LeafError),
48#[error(transparent)]
49Recursive(#[from] crate::RecursiveError),
50}
5152impl Error {
53pub(crate) fn certificate_validation<E>(context: &'static str) -> impl FnOnce(E) -> Self
54where
55E: std::fmt::Debug,
56 {
57move |source| Self::CertificateValidation {
58 context,
59 upstream: format!("{source:?}"),
60 }
61 }
62}