Skip to main content

auths_sdk/
error.rs

1pub use auths_core::error::AuthsErrorInfo;
2use thiserror::Error;
3
4/// Typed storage errors originating from the `auths-id` layer.
5///
6/// Usage:
7/// ```ignore
8/// storage.save(data)
9///     .map_err(|e| SetupError::StorageError(e.into()))?;
10/// ```
11#[derive(Debug, Error)]
12#[non_exhaustive]
13pub enum SdkStorageError {
14    /// Identity or attestation storage operation failed (identity layer).
15    #[error(transparent)]
16    Identity(#[from] auths_id::error::StorageError),
17
18    /// Identity initialization failed.
19    #[error(transparent)]
20    Init(#[from] auths_id::error::InitError),
21
22    /// Driver-level storage operation failed.
23    #[error(transparent)]
24    Driver(#[from] auths_id::storage::StorageError),
25
26    /// Attestation creation failed.
27    #[error(transparent)]
28    Attestation(#[from] auths_verifier::error::AttestationError),
29}
30
31impl AuthsErrorInfo for SdkStorageError {
32    fn error_code(&self) -> &'static str {
33        match self {
34            Self::Identity(e) => e.error_code(),
35            Self::Init(e) => e.error_code(),
36            Self::Driver(e) => e.error_code(),
37            Self::Attestation(e) => e.error_code(),
38        }
39    }
40
41    fn suggestion(&self) -> Option<&'static str> {
42        match self {
43            Self::Identity(e) => e.suggestion(),
44            Self::Init(e) => e.suggestion(),
45            Self::Driver(e) => e.suggestion(),
46            Self::Attestation(e) => e.suggestion(),
47        }
48    }
49}
50
51/// Re-export identity domain errors for backwards compatibility.
52pub use crate::domains::identity::error::{RegistrationError, RotationError, SetupError};
53
54/// Re-export device domain errors for backwards compatibility.
55pub use crate::domains::device::error::{DeviceError, DeviceExtensionError};
56
57/// Re-export auth domain errors for backwards compatibility.
58pub use crate::domains::auth::error::{McpAuthError, TrustError};
59
60/// Re-export org domain errors for backwards compatibility.
61pub use crate::domains::org::error::OrgError;
62
63/// Re-export compliance domain errors for backwards compatibility.
64pub use crate::domains::compliance::error::ApprovalError;
65
66/// Re-export from `auths-core` — defined there to avoid a circular dependency with
67/// `auths-infra-http` (which implements the platform port traits).
68pub use auths_core::ports::platform::PlatformError;
69
70// Re-exported error types from auths-core for CLI error rendering
71pub use auths_core::error::AgentError;
72pub use auths_core::error::TrustError as CoreTrustError;
73pub use auths_core::pairing::PairingError;
74
75// Re-exported error types from auths-id for CLI error rendering
76pub use auths_id::error::FreezeError;
77pub use auths_id::error::InitError;
78pub use auths_id::error::StorageError as IdStorageError;
79pub use auths_id::storage::StorageError as IdDriverStorageError;