bitwarden_uniffi/
error.rs

1use bitwarden_exporters::ExportError;
2use bitwarden_generators::{PassphraseError, PasswordError, UsernameError};
3
4pub type Result<T, E = BitwardenError> = std::result::Result<T, E>;
5pub type Error = BitwardenError;
6
7// Name is converted from *Error to *Exception, so we can't just name the enum Error because
8// Exception already exists
9#[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    AuthValidate(#[from] bitwarden_core::auth::AuthValidateError),
27    #[error(transparent)]
28    ApproveAuthRequest(#[from] bitwarden_core::auth::ApproveAuthRequestError),
29    #[error(transparent)]
30    TrustDevice(#[from] bitwarden_core::auth::auth_client::TrustDeviceError),
31
32    #[error(transparent)]
33    Fingerprint(#[from] bitwarden_core::platform::FingerprintError),
34    #[error(transparent)]
35    UserFingerprint(#[from] bitwarden_core::platform::UserFingerprintError),
36
37    #[error(transparent)]
38    Crypto(#[from] bitwarden_crypto::CryptoError),
39
40    #[error(transparent)]
41    StateRegistry(#[from] bitwarden_state::registry::StateRegistryError),
42
43    // Generators
44    #[error(transparent)]
45    Username(#[from] UsernameError),
46    #[error(transparent)]
47    Passphrase(#[from] PassphraseError),
48    #[error(transparent)]
49    Password(#[from] PasswordError),
50
51    // Vault
52    #[error(transparent)]
53    Cipher(#[from] bitwarden_vault::CipherError),
54    #[error(transparent)]
55    Totp(#[from] bitwarden_vault::TotpError),
56    #[error(transparent)]
57    Decrypt(#[from] bitwarden_vault::DecryptError),
58    #[error(transparent)]
59    DecryptFile(#[from] bitwarden_vault::DecryptFileError),
60    #[error(transparent)]
61    Encrypt(#[from] bitwarden_vault::EncryptError),
62    #[error(transparent)]
63    EncryptFile(#[from] bitwarden_vault::EncryptFileError),
64
65    // Send
66    #[error(transparent)]
67    SendDecrypt(#[from] bitwarden_send::SendDecryptError),
68    #[error(transparent)]
69    SendDecryptFile(#[from] bitwarden_send::SendDecryptFileError),
70    #[error(transparent)]
71    SendEncrypt(#[from] bitwarden_send::SendEncryptError),
72    #[error(transparent)]
73    SendEncryptFile(#[from] bitwarden_send::SendEncryptFileError),
74
75    #[error(transparent)]
76    Export(#[from] ExportError),
77
78    // Fido
79    #[error(transparent)]
80    MakeCredential(#[from] bitwarden_fido::MakeCredentialError),
81    #[error(transparent)]
82    GetAssertion(#[from] bitwarden_fido::GetAssertionError),
83    #[error(transparent)]
84    SilentlyDiscoverCredentials(#[from] bitwarden_fido::SilentlyDiscoverCredentialsError),
85    #[error(transparent)]
86    CredentialsForAutofill(#[from] bitwarden_fido::CredentialsForAutofillError),
87    #[error(transparent)]
88    DecryptFido2AutofillCredentials(#[from] bitwarden_fido::DecryptFido2AutofillCredentialsError),
89    #[error(transparent)]
90    Fido2Client(#[from] bitwarden_fido::Fido2ClientError),
91
92    #[error(transparent)]
93    SshGeneration(#[from] bitwarden_ssh::error::KeyGenerationError),
94    #[error(transparent)]
95    SshImport(#[from] bitwarden_ssh::error::SshKeyImportError),
96
97    #[error("A conversion error occurred: {0}")]
98    Conversion(String),
99}