aws_secrets/
errors.rs

1use thiserror::Error;
2
3#[cfg(feature = "sm")]
4mod sm_imports {
5    pub(crate) use aws_sdk_secretsmanager::error::{GetSecretValueError, TagResourceError};
6    pub(crate) use aws_sdk_secretsmanager::types::SdkError as SMError;
7}
8#[cfg(feature = "sm")]
9use sm_imports::*;
10
11#[cfg(feature = "params")]
12mod params_imports {
13    pub(crate) use aws_sdk_ssm::error::GetParameterError;
14    pub(crate) use aws_sdk_ssm::types::SdkError as ParamsError;
15}
16#[cfg(feature = "params")]
17use params_imports::*;
18
19/// Library-specific errors
20#[derive(Error, Debug)]
21#[non_exhaustive]
22pub enum Error {
23    /// Raised when an error occurs in the `secretsmanager:TagResource` operation
24    #[cfg(feature = "sm")]
25    #[error("couldn't set tag")]
26    SetTag(#[from] SMError<TagResourceError>),
27    /// Indicates a `serde` error when de-serializing a JSON string.
28    #[cfg(feature = "sm")]
29    #[error("couldn't deserialize secret string")]
30    DeserializeError(#[from] serde_json::Error),
31    /// Raised when an error occurs in the `ssm:GetParameter` operation
32    #[cfg(feature = "params")]
33    #[error("[{param_name:?}] couldn't read param")]
34    ReadParam {
35        /// Name of the Parameter to retrieve
36        param_name: String,
37        /// Original error
38        source: ParamsError<GetParameterError>,
39    },
40    /// Raised when an error occurs in the `secretsmanager:GetSecretValue` operation
41    #[cfg(feature = "sm")]
42    #[error("[{secret_name:?}] couldn't read secret")]
43    ReadSecret {
44        /// Name of the Secret to retrieve
45        secret_name: String,
46        /// Original error
47        source: SMError<GetSecretValueError>,
48    },
49    /// Unknown library error (currently unused)
50    #[error("unknown error")]
51    Unknown,
52}