1use aws_credential_types::provider::error::CredentialsError;
2use aws_sdk_sts::operation::get_caller_identity::GetCallerIdentityError;
3use aws_sdk_sts::operation::get_session_token::GetSessionTokenError;
4use aws_smithy_runtime_api::client::orchestrator::HttpResponse;
5use aws_smithy_runtime_api::client::result::SdkError;
6use std::env::VarError;
7use std::io;
8use std::num::ParseIntError;
9use thiserror::Error;
10use time::error::ComponentRange;
11
12#[derive(Error, Debug)]
13pub enum Error {
14 #[error("failed to get caller identity")]
15 GetCallerIdentityError(#[source] Box<SdkError<GetCallerIdentityError, HttpResponse>>),
16
17 #[error("failed to get session token")]
18 GetSessionTokenError(#[source] Box<SdkError<GetSessionTokenError, HttpResponse>>),
19
20 #[error("failed to provide credentials")]
21 ProvideCredentialsError(#[source] CredentialsError),
22
23 #[error("could not read credentials file `{path:?}`")]
24 ReadCredentialsFileError { path: String, source: io::Error },
25
26 #[error("could not write in credentials file `{path:?}`")]
27 WriteCredentialsFileError { path: String, source: io::Error },
28
29 #[error("failed to get environment variable `{var:?}`")]
30 GetEnvVariableError { var: String, source: VarError },
31
32 #[error("missing field `{0}` in session token")]
33 InvalidSession(String),
34
35 #[error("missing field `{0}` in session credentials")]
36 InvalidCredentials(String),
37
38 #[error("missing field `{0}` in caller identity")]
39 InvalidIdentity(String),
40
41 #[error("failed to parse session timestamp")]
42 ParseSessionTimestampError(#[source] ParseIntError),
43
44 #[error("failed to convert session timestamp to datetime")]
45 ConvertSessionTimestampError(#[source] ComponentRange),
46
47 #[error(transparent)]
48 Other(#[from] anyhow::Error),
49}