Skip to main content

bitwarden_pam/rotation/
error.rs

1use bitwarden_access_token::AccessTokenError;
2use bitwarden_core::{ApiError, MissingFieldError};
3use bitwarden_crypto::{CryptoError, safe::DataEnvelopeError};
4use bitwarden_error::bitwarden_error;
5use thiserror::Error;
6
7use super::validate::RotationValidationError;
8
9/// Errors returned from the PAM rotation clients.
10#[bitwarden_error(flat)]
11#[derive(Debug, Error)]
12pub enum RotationError {
13    /// The request failed local validation before being sent to the server.
14    #[error(transparent)]
15    Validation(#[from] RotationValidationError),
16    /// The server response was missing a field required to build the requested type.
17    #[error(transparent)]
18    MissingField(#[from] MissingFieldError),
19    /// A date field in the server response could not be parsed.
20    #[error(transparent)]
21    Chrono(#[from] chrono::ParseError),
22    /// A caller passed an `Unknown` variant (a value only a newer server returns) in a field sent
23    /// back to the server, which the SDK cannot name on the wire.
24    #[error("Cannot send a variant this SDK version does not recognize to the server")]
25    UnrecognizedVariant,
26    /// The caller is not a member of the organization they addressed, or its key is not in the
27    /// key store.
28    #[error("The organization key is unavailable")]
29    MissingOrganizationKey,
30    /// A cryptographic operation failed while registering a connector.
31    #[error(transparent)]
32    Crypto(#[from] CryptoError),
33    /// Minting a connector's access-token secrets failed.
34    #[error(transparent)]
35    AccessToken(#[from] AccessTokenError),
36    /// Sealing a blob failed. Unsealing failures degrade to `None` instead.
37    #[error(transparent)]
38    Sealed(#[from] DataEnvelopeError),
39    /// The named target system does not exist in this organization.
40    #[error("Target system not found")]
41    TargetSystemNotFound,
42    /// A network or (de)serialization error occurred while calling the server.
43    #[error(transparent)]
44    Api(#[from] ApiError),
45}