bitwarden_uniffi/
error.rs1use bitwarden_exporters::ExportError;
2use bitwarden_generators::{PassphraseError, PasswordError, PasswordRulesError, UsernameError};
3
4pub type Result<T, E = BitwardenError> = std::result::Result<T, E>;
5pub type Error = BitwardenError;
6
7#[derive(uniffi::Error, thiserror::Error, Debug)]
14pub enum BitwardenError {
15 #[error(transparent)]
16 Api(#[from] bitwarden_core::ApiError),
17 #[error(transparent)]
18 DeriveKeyConnector(#[from] bitwarden_core::key_management::crypto::DeriveKeyConnectorError),
19 #[error(transparent)]
20 EncryptionSettings(
21 #[from] bitwarden_core::client::encryption_settings::EncryptionSettingsError,
22 ),
23 #[error(transparent)]
24 EnrollAdminPasswordReset(
25 #[from] bitwarden_core::key_management::crypto::EnrollAdminPasswordResetError,
26 ),
27 #[error(transparent)]
28 MobileCrypto(#[from] bitwarden_core::key_management::crypto::CryptoClientError),
29 #[error(transparent)]
30 ReinitUserCrypto(#[from] bitwarden_core::key_management::crypto::ReinitUserCryptoError),
31 #[error(transparent)]
32 AuthValidate(#[from] bitwarden_core::auth::AuthValidateError),
33 #[error(transparent)]
34 ApproveAuthRequest(#[from] bitwarden_core::auth::ApproveAuthRequestError),
35 #[error(transparent)]
36 TrustDevice(#[from] bitwarden_core::auth::auth_client::TrustDeviceError),
37 #[error(transparent)]
38 Registration(#[from] bitwarden_auth::registration::RegistrationError),
39 #[error(transparent)]
40 PasswordPrelogin(#[from] bitwarden_auth::login::login_via_password::PasswordPreloginError),
41 #[error(transparent)]
42 PasswordLogin(#[from] bitwarden_auth::login::login_via_password::PasswordLoginError),
43
44 #[error(transparent)]
45 Fingerprint(#[from] bitwarden_core::platform::FingerprintError),
46 #[error(transparent)]
47 UserFingerprint(#[from] bitwarden_core::platform::UserFingerprintError),
48
49 #[error(transparent)]
50 Crypto(#[from] bitwarden_crypto::CryptoError),
51
52 #[error(transparent)]
53 StateRegistry(#[from] bitwarden_state::registry::StateRegistryError),
54
55 #[error(transparent)]
57 Username(#[from] UsernameError),
58 #[error(transparent)]
59 Passphrase(#[from] PassphraseError),
60 #[error(transparent)]
61 Password(#[from] PasswordError),
62 #[error(transparent)]
63 PasswordRules(#[from] PasswordRulesError),
64
65 #[error(transparent)]
67 Cipher(#[from] bitwarden_vault::CipherError),
68 #[error(transparent)]
69 Totp(#[from] bitwarden_vault::TotpError),
70 #[error(transparent)]
71 Decrypt(#[from] bitwarden_vault::DecryptError),
72 #[error(transparent)]
73 DecryptFile(#[from] bitwarden_vault::DecryptFileError),
74 #[error(transparent)]
75 Encrypt(#[from] bitwarden_vault::EncryptError),
76 #[error(transparent)]
77 EncryptFile(#[from] bitwarden_vault::EncryptFileError),
78
79 #[error(transparent)]
81 CollectionDecrypt(#[from] bitwarden_collections::error::CollectionDecryptError),
82 #[error(transparent)]
83 CollectionEncrypt(#[from] bitwarden_collections::error::CollectionEncryptError),
84
85 #[error(transparent)]
87 SendDecrypt(#[from] bitwarden_send::SendDecryptError),
88 #[error(transparent)]
89 SendDecryptFile(#[from] bitwarden_send::SendDecryptFileError),
90 #[error(transparent)]
91 SendEncrypt(#[from] bitwarden_send::SendEncryptError),
92 #[error(transparent)]
93 SendEncryptFile(#[from] bitwarden_send::SendEncryptFileError),
94
95 #[error(transparent)]
96 Export(#[from] ExportError),
97 #[error(transparent)]
98 Import(#[from] bitwarden_importers::ImportError),
99
100 #[error(transparent)]
102 MakeCredential(#[from] bitwarden_fido::MakeCredentialError),
103 #[error(transparent)]
104 GetAssertion(#[from] bitwarden_fido::GetAssertionError),
105 #[error(transparent)]
106 SilentlyDiscoverCredentials(#[from] bitwarden_fido::SilentlyDiscoverCredentialsError),
107 #[error(transparent)]
108 CredentialsForAutofill(#[from] bitwarden_fido::CredentialsForAutofillError),
109 #[error(transparent)]
110 GetFido2AutofillCredentials(#[from] bitwarden_fido::GetFido2AutofillCredentialsError),
111 #[error(transparent)]
112 Fido2Client(#[from] bitwarden_fido::Fido2ClientError),
113 #[error(transparent)]
114 DeviceAuthKey(#[from] bitwarden_fido::DeviceAuthKeyError),
115
116 #[error(transparent)]
117 SshGeneration(#[from] bitwarden_ssh::error::KeyGenerationError),
118 #[error(transparent)]
119 SshImport(#[from] bitwarden_ssh::error::SshKeyImportError),
120
121 #[error(transparent)]
122 AcquireCookie(#[from] bitwarden_server_communication_config::AcquireCookieError),
123
124 #[error("Callback invocation failed")]
125 Callback,
126
127 #[error("A conversion error occurred: {0}")]
128 Conversion(String),
129}
130impl From<uniffi::UnexpectedUniFFICallbackError> for BitwardenError {
133 fn from(_: uniffi::UnexpectedUniFFICallbackError) -> Self {
134 Self::Callback
135 }
136}