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)]
10pub enum BitwardenError {
11 #[error(transparent)]
12 Api(#[from] bitwarden_core::ApiError),
13 #[error(transparent)]
14 DeriveKeyConnector(#[from] bitwarden_core::key_management::crypto::DeriveKeyConnectorError),
15 #[error(transparent)]
16 EncryptionSettings(
17 #[from] bitwarden_core::client::encryption_settings::EncryptionSettingsError,
18 ),
19 #[error(transparent)]
20 EnrollAdminPasswordReset(
21 #[from] bitwarden_core::key_management::crypto::EnrollAdminPasswordResetError,
22 ),
23 #[error(transparent)]
24 MobileCrypto(#[from] bitwarden_core::key_management::crypto::CryptoClientError),
25 #[error(transparent)]
26 ReinitUserCrypto(#[from] bitwarden_core::key_management::crypto::ReinitUserCryptoError),
27 #[error(transparent)]
28 AuthValidate(#[from] bitwarden_core::auth::AuthValidateError),
29 #[error(transparent)]
30 ApproveAuthRequest(#[from] bitwarden_core::auth::ApproveAuthRequestError),
31 #[error(transparent)]
32 TrustDevice(#[from] bitwarden_core::auth::auth_client::TrustDeviceError),
33 #[error(transparent)]
34 Registration(#[from] bitwarden_auth::registration::RegistrationError),
35
36 #[error(transparent)]
37 Fingerprint(#[from] bitwarden_core::platform::FingerprintError),
38 #[error(transparent)]
39 UserFingerprint(#[from] bitwarden_core::platform::UserFingerprintError),
40
41 #[error(transparent)]
42 Crypto(#[from] bitwarden_crypto::CryptoError),
43
44 #[error(transparent)]
45 StateRegistry(#[from] bitwarden_state::registry::StateRegistryError),
46
47 #[error(transparent)]
49 Username(#[from] UsernameError),
50 #[error(transparent)]
51 Passphrase(#[from] PassphraseError),
52 #[error(transparent)]
53 Password(#[from] PasswordError),
54 #[error(transparent)]
55 PasswordRules(#[from] PasswordRulesError),
56
57 #[error(transparent)]
59 Cipher(#[from] bitwarden_vault::CipherError),
60 #[error(transparent)]
61 Totp(#[from] bitwarden_vault::TotpError),
62 #[error(transparent)]
63 Decrypt(#[from] bitwarden_vault::DecryptError),
64 #[error(transparent)]
65 DecryptFile(#[from] bitwarden_vault::DecryptFileError),
66 #[error(transparent)]
67 Encrypt(#[from] bitwarden_vault::EncryptError),
68 #[error(transparent)]
69 EncryptFile(#[from] bitwarden_vault::EncryptFileError),
70
71 #[error(transparent)]
73 SendDecrypt(#[from] bitwarden_send::SendDecryptError),
74 #[error(transparent)]
75 SendDecryptFile(#[from] bitwarden_send::SendDecryptFileError),
76 #[error(transparent)]
77 SendEncrypt(#[from] bitwarden_send::SendEncryptError),
78 #[error(transparent)]
79 SendEncryptFile(#[from] bitwarden_send::SendEncryptFileError),
80
81 #[error(transparent)]
82 Export(#[from] ExportError),
83 #[error(transparent)]
84 Import(#[from] bitwarden_importers::ImportError),
85
86 #[error(transparent)]
88 MakeCredential(#[from] bitwarden_fido::MakeCredentialError),
89 #[error(transparent)]
90 GetAssertion(#[from] bitwarden_fido::GetAssertionError),
91 #[error(transparent)]
92 SilentlyDiscoverCredentials(#[from] bitwarden_fido::SilentlyDiscoverCredentialsError),
93 #[error(transparent)]
94 CredentialsForAutofill(#[from] bitwarden_fido::CredentialsForAutofillError),
95 #[error(transparent)]
96 DecryptFido2AutofillCredentials(#[from] bitwarden_fido::DecryptFido2AutofillCredentialsError),
97 #[error(transparent)]
98 Fido2Client(#[from] bitwarden_fido::Fido2ClientError),
99 #[error(transparent)]
100 DeviceAuthKey(#[from] bitwarden_fido::DeviceAuthKeyError),
101
102 #[error(transparent)]
103 SshGeneration(#[from] bitwarden_ssh::error::KeyGenerationError),
104 #[error(transparent)]
105 SshImport(#[from] bitwarden_ssh::error::SshKeyImportError),
106
107 #[error(transparent)]
108 AcquireCookie(#[from] bitwarden_server_communication_config::AcquireCookieError),
109
110 #[error("Callback invocation failed")]
111 Callback,
112
113 #[error("A conversion error occurred: {0}")]
114 Conversion(String),
115}
116impl From<uniffi::UnexpectedUniFFICallbackError> for BitwardenError {
119 fn from(_: uniffi::UnexpectedUniFFICallbackError) -> Self {
120 Self::Callback
121 }
122}