Skip to main content

awscreds/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum CredentialsError {
5    #[error("Not an AWS instance")]
6    NotEc2,
7    #[error("Not a container")]
8    NotContainer,
9    #[cfg(feature = "http-credentials")]
10    #[error("invalid container credentials endpoint")]
11    InvalidContainerCredentialsUri,
12    #[cfg(feature = "http-credentials")]
13    #[error("invalid container credentials authorization token")]
14    InvalidContainerAuthorization,
15    #[cfg(feature = "http-credentials")]
16    #[error("container credentials request failed")]
17    ContainerCredentialsRequest,
18    #[error("Config not found")]
19    ConfigNotFound,
20    #[error("Missing aws_access_key_id section in config")]
21    ConfigMissingAccessKeyId,
22    #[error("Missing aws_access_key_id section in config")]
23    ConfigMissingSecretKey,
24    #[error("Neither {0}, nor {1} exists in the environment")]
25    MissingEnvVar(String, String),
26    #[cfg(feature = "http-credentials")]
27    #[error("attohttpc: {0}")]
28    Atto(#[from] attohttpc::Error),
29    #[error("ini: {0}")]
30    Ini(#[from] ini::Error),
31    #[error("serde_xml: {0}")]
32    SerdeXml(#[from] quick_xml::de::DeError),
33    #[error("url parse: {0}")]
34    UrlParse(#[from] url::ParseError),
35    #[error("io: {0}")]
36    Io(#[from] std::io::Error),
37    #[error("env var: {0}")]
38    Env(#[from] std::env::VarError),
39    #[error("Invalid home dir")]
40    HomeDir,
41    #[error("Could not get valid credentials from STS, ENV, Profile or Instance metadata")]
42    NoCredentials,
43    #[error("expired credentials have no refresh source; reload or replace credentials")]
44    NoRefreshSource,
45    #[error("unexpected status code: {0}")]
46    UnexpectedStatusCode(u16),
47}