bitwarden_uniffi/
error.rs1use std::fmt::{Display, Formatter};
2
3use bitwarden_exporters::ExportError;
4use bitwarden_generators::{PassphraseError, PasswordError, UsernameError};
5
6#[derive(uniffi::Error, Debug)]
9#[uniffi(flat_error)]
10pub enum BitwardenError {
11 E(Error),
12}
13
14impl From<Error> for BitwardenError {
15 fn from(e: Error) -> Self {
16 Self::E(e)
17 }
18}
19
20impl Display for BitwardenError {
21 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
22 match self {
23 Self::E(e) => Display::fmt(e, f),
24 }
25 }
26}
27
28impl std::error::Error for BitwardenError {
29 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
30 match self {
31 BitwardenError::E(e) => Some(e),
32 }
33 }
34}
35
36pub type Result<T, E = BitwardenError> = std::result::Result<T, E>;
37
38#[derive(thiserror::Error, Debug)]
39pub enum Error {
40 #[error(transparent)]
41 Api(#[from] bitwarden_core::ApiError),
42 #[error(transparent)]
43 DeriveKeyConnector(#[from] bitwarden_core::key_management::crypto::DeriveKeyConnectorError),
44 #[error(transparent)]
45 EncryptionSettings(
46 #[from] bitwarden_core::client::encryption_settings::EncryptionSettingsError,
47 ),
48 #[error(transparent)]
49 EnrollAdminPasswordReset(
50 #[from] bitwarden_core::key_management::crypto::EnrollAdminPasswordResetError,
51 ),
52 #[error(transparent)]
53 MobileCrypto(#[from] bitwarden_core::key_management::crypto::CryptoClientError),
54 #[error(transparent)]
55 AuthValidate(#[from] bitwarden_core::auth::AuthValidateError),
56 #[error(transparent)]
57 ApproveAuthRequest(#[from] bitwarden_core::auth::ApproveAuthRequestError),
58 #[error(transparent)]
59 TrustDevice(#[from] bitwarden_core::auth::auth_client::TrustDeviceError),
60
61 #[error(transparent)]
62 Fingerprint(#[from] bitwarden_core::platform::FingerprintError),
63 #[error(transparent)]
64 UserFingerprint(#[from] bitwarden_core::platform::UserFingerprintError),
65
66 #[error(transparent)]
67 Crypto(#[from] bitwarden_crypto::CryptoError),
68
69 #[error(transparent)]
71 Username(#[from] UsernameError),
72 #[error(transparent)]
73 Passphrase(#[from] PassphraseError),
74 #[error(transparent)]
75 Password(#[from] PasswordError),
76
77 #[error(transparent)]
79 Cipher(#[from] bitwarden_vault::CipherError),
80 #[error(transparent)]
81 Totp(#[from] bitwarden_vault::TotpError),
82 #[error(transparent)]
83 Decrypt(#[from] bitwarden_vault::DecryptError),
84 #[error(transparent)]
85 DecryptFile(#[from] bitwarden_vault::DecryptFileError),
86 #[error(transparent)]
87 Encrypt(#[from] bitwarden_vault::EncryptError),
88 #[error(transparent)]
89 EncryptFile(#[from] bitwarden_vault::EncryptFileError),
90
91 #[error(transparent)]
93 SendDecrypt(#[from] bitwarden_send::SendDecryptError),
94 #[error(transparent)]
95 SendDecryptFile(#[from] bitwarden_send::SendDecryptFileError),
96 #[error(transparent)]
97 SendEncrypt(#[from] bitwarden_send::SendEncryptError),
98 #[error(transparent)]
99 SendEncryptFile(#[from] bitwarden_send::SendEncryptFileError),
100
101 #[error(transparent)]
102 Export(#[from] ExportError),
103
104 #[error(transparent)]
106 MakeCredential(#[from] bitwarden_fido::MakeCredentialError),
107 #[error(transparent)]
108 GetAssertion(#[from] bitwarden_fido::GetAssertionError),
109 #[error(transparent)]
110 SilentlyDiscoverCredentials(#[from] bitwarden_fido::SilentlyDiscoverCredentialsError),
111 #[error(transparent)]
112 CredentialsForAutofill(#[from] bitwarden_fido::CredentialsForAutofillError),
113 #[error(transparent)]
114 DecryptFido2AutofillCredentials(#[from] bitwarden_fido::DecryptFido2AutofillCredentialsError),
115 #[error(transparent)]
116 Fido2Client(#[from] bitwarden_fido::Fido2ClientError),
117
118 #[error(transparent)]
119 SshGeneration(#[from] bitwarden_ssh::error::KeyGenerationError),
120 #[error(transparent)]
121 SshImport(#[from] bitwarden_ssh::error::SshKeyImportError),
122}