aws_sdk_sts/
error_meta.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2/// All possible error types for this service.
3#[non_exhaustive]
4#[derive(::std::fmt::Debug)]
5pub enum Error {
6    /// <p>The web identity token that was passed is expired or is not valid. Get a new identity token from the identity provider and then retry the request.</p>
7    ExpiredTokenException(crate::types::error::ExpiredTokenException),
8    /// <p>The request could not be fulfilled because the identity provider (IDP) that was asked to verify the incoming identity token could not be reached. This is often a transient error caused by network conditions. Retry the request a limited number of times so that you don't exceed the request rate. If the error persists, the identity provider might be down or not responding.</p>
9    IdpCommunicationErrorException(crate::types::error::IdpCommunicationErrorException),
10    /// <p>The identity provider (IdP) reported that authentication failed. This might be because the claim is invalid.</p>
11    /// <p>If this error is returned for the <code>AssumeRoleWithWebIdentity</code> operation, it can also mean that the claim has expired or has been explicitly revoked.</p>
12    IdpRejectedClaimException(crate::types::error::IdpRejectedClaimException),
13    /// <p>The error returned if the message passed to <code>DecodeAuthorizationMessage</code> was invalid. This can happen if the token contains invalid characters, such as line breaks, or if the message has expired.</p>
14    InvalidAuthorizationMessageException(crate::types::error::InvalidAuthorizationMessageException),
15    /// <p>The web identity token that was passed could not be validated by Amazon Web Services. Get a new identity token from the identity provider and then retry the request.</p>
16    InvalidIdentityTokenException(crate::types::error::InvalidIdentityTokenException),
17    /// <p>The request was rejected because the policy document was malformed. The error message describes the specific error.</p>
18    MalformedPolicyDocumentException(crate::types::error::MalformedPolicyDocumentException),
19    /// <p>The request was rejected because the total packed size of the session policies and session tags combined was too large. An Amazon Web Services conversion compresses the session policy document, session policy ARNs, and session tags into a packed binary format that has a separate limit. The error message indicates by percentage how close the policies and tags are to the upper size limit. For more information, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_session-tags.html">Passing Session Tags in STS</a> in the <i>IAM User Guide</i>.</p>
20    /// <p>You could receive this error even though you meet other defined session policy and session tag limits. For more information, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html#reference_iam-limits-entity-length">IAM and STS Entity Character Limits</a> in the <i>IAM User Guide</i>.</p>
21    PackedPolicyTooLargeException(crate::types::error::PackedPolicyTooLargeException),
22    /// <p>STS is not activated in the requested region for the account that is being asked to generate credentials. The account administrator must use the IAM console to activate STS in that region. For more information, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_enable-regions.html">Activating and Deactivating STS in an Amazon Web Services Region</a> in the <i>IAM User Guide</i>.</p>
23    RegionDisabledException(crate::types::error::RegionDisabledException),
24    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
25    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
26    variable wildcard pattern and check `.code()`:
27     \
28    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
29     \
30    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-Error) for what information is available for the error.")]
31    Unhandled(crate::error::sealed_unhandled::Unhandled),
32}
33impl ::std::fmt::Display for Error {
34    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
35        match self {
36            Error::ExpiredTokenException(inner) => inner.fmt(f),
37            Error::IdpCommunicationErrorException(inner) => inner.fmt(f),
38            Error::IdpRejectedClaimException(inner) => inner.fmt(f),
39            Error::InvalidAuthorizationMessageException(inner) => inner.fmt(f),
40            Error::InvalidIdentityTokenException(inner) => inner.fmt(f),
41            Error::MalformedPolicyDocumentException(inner) => inner.fmt(f),
42            Error::PackedPolicyTooLargeException(inner) => inner.fmt(f),
43            Error::RegionDisabledException(inner) => inner.fmt(f),
44            Error::Unhandled(_) => {
45                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
46                    write!(f, "unhandled error ({code})")
47                } else {
48                    f.write_str("unhandled error")
49                }
50            }
51        }
52    }
53}
54impl From<::aws_smithy_types::error::operation::BuildError> for Error {
55    fn from(value: ::aws_smithy_types::error::operation::BuildError) -> Self {
56        Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
57            source: value.into(),
58            meta: ::std::default::Default::default(),
59        })
60    }
61}
62impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for Error {
63    fn meta(&self) -> &::aws_smithy_types::error::metadata::ErrorMetadata {
64        match self {
65            Self::ExpiredTokenException(inner) => inner.meta(),
66            Self::IdpCommunicationErrorException(inner) => inner.meta(),
67            Self::IdpRejectedClaimException(inner) => inner.meta(),
68            Self::InvalidAuthorizationMessageException(inner) => inner.meta(),
69            Self::InvalidIdentityTokenException(inner) => inner.meta(),
70            Self::MalformedPolicyDocumentException(inner) => inner.meta(),
71            Self::PackedPolicyTooLargeException(inner) => inner.meta(),
72            Self::RegionDisabledException(inner) => inner.meta(),
73            Self::Unhandled(inner) => &inner.meta,
74        }
75    }
76}
77impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::assume_role::AssumeRoleError, R>> for Error
78where
79    R: Send + Sync + std::fmt::Debug + 'static,
80{
81    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::assume_role::AssumeRoleError, R>) -> Self {
82        match err {
83            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
84            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
85                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
86                source: err.into(),
87            }),
88        }
89    }
90}
91impl From<crate::operation::assume_role::AssumeRoleError> for Error {
92    fn from(err: crate::operation::assume_role::AssumeRoleError) -> Self {
93        match err {
94            crate::operation::assume_role::AssumeRoleError::ExpiredTokenException(inner) => Error::ExpiredTokenException(inner),
95            crate::operation::assume_role::AssumeRoleError::MalformedPolicyDocumentException(inner) => Error::MalformedPolicyDocumentException(inner),
96            crate::operation::assume_role::AssumeRoleError::PackedPolicyTooLargeException(inner) => Error::PackedPolicyTooLargeException(inner),
97            crate::operation::assume_role::AssumeRoleError::RegionDisabledException(inner) => Error::RegionDisabledException(inner),
98            crate::operation::assume_role::AssumeRoleError::Unhandled(inner) => Error::Unhandled(inner),
99        }
100    }
101}
102impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::assume_role_with_saml::AssumeRoleWithSAMLError, R>> for Error
103where
104    R: Send + Sync + std::fmt::Debug + 'static,
105{
106    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::assume_role_with_saml::AssumeRoleWithSAMLError, R>) -> Self {
107        match err {
108            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
109            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
110                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
111                source: err.into(),
112            }),
113        }
114    }
115}
116impl From<crate::operation::assume_role_with_saml::AssumeRoleWithSAMLError> for Error {
117    fn from(err: crate::operation::assume_role_with_saml::AssumeRoleWithSAMLError) -> Self {
118        match err {
119            crate::operation::assume_role_with_saml::AssumeRoleWithSAMLError::ExpiredTokenException(inner) => Error::ExpiredTokenException(inner),
120            crate::operation::assume_role_with_saml::AssumeRoleWithSAMLError::IdpRejectedClaimException(inner) => {
121                Error::IdpRejectedClaimException(inner)
122            }
123            crate::operation::assume_role_with_saml::AssumeRoleWithSAMLError::InvalidIdentityTokenException(inner) => {
124                Error::InvalidIdentityTokenException(inner)
125            }
126            crate::operation::assume_role_with_saml::AssumeRoleWithSAMLError::MalformedPolicyDocumentException(inner) => {
127                Error::MalformedPolicyDocumentException(inner)
128            }
129            crate::operation::assume_role_with_saml::AssumeRoleWithSAMLError::PackedPolicyTooLargeException(inner) => {
130                Error::PackedPolicyTooLargeException(inner)
131            }
132            crate::operation::assume_role_with_saml::AssumeRoleWithSAMLError::RegionDisabledException(inner) => Error::RegionDisabledException(inner),
133            crate::operation::assume_role_with_saml::AssumeRoleWithSAMLError::Unhandled(inner) => Error::Unhandled(inner),
134        }
135    }
136}
137impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError, R>>
138    for Error
139where
140    R: Send + Sync + std::fmt::Debug + 'static,
141{
142    fn from(
143        err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError, R>,
144    ) -> Self {
145        match err {
146            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
147            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
148                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
149                source: err.into(),
150            }),
151        }
152    }
153}
154impl From<crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError> for Error {
155    fn from(err: crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError) -> Self {
156        match err {
157            crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError::ExpiredTokenException(inner) => {
158                Error::ExpiredTokenException(inner)
159            }
160            crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError::IdpCommunicationErrorException(inner) => {
161                Error::IdpCommunicationErrorException(inner)
162            }
163            crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError::IdpRejectedClaimException(inner) => {
164                Error::IdpRejectedClaimException(inner)
165            }
166            crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError::InvalidIdentityTokenException(inner) => {
167                Error::InvalidIdentityTokenException(inner)
168            }
169            crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError::MalformedPolicyDocumentException(inner) => {
170                Error::MalformedPolicyDocumentException(inner)
171            }
172            crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError::PackedPolicyTooLargeException(inner) => {
173                Error::PackedPolicyTooLargeException(inner)
174            }
175            crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError::RegionDisabledException(inner) => {
176                Error::RegionDisabledException(inner)
177            }
178            crate::operation::assume_role_with_web_identity::AssumeRoleWithWebIdentityError::Unhandled(inner) => Error::Unhandled(inner),
179        }
180    }
181}
182impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::assume_root::AssumeRootError, R>> for Error
183where
184    R: Send + Sync + std::fmt::Debug + 'static,
185{
186    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::assume_root::AssumeRootError, R>) -> Self {
187        match err {
188            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
189            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
190                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
191                source: err.into(),
192            }),
193        }
194    }
195}
196impl From<crate::operation::assume_root::AssumeRootError> for Error {
197    fn from(err: crate::operation::assume_root::AssumeRootError) -> Self {
198        match err {
199            crate::operation::assume_root::AssumeRootError::ExpiredTokenException(inner) => Error::ExpiredTokenException(inner),
200            crate::operation::assume_root::AssumeRootError::RegionDisabledException(inner) => Error::RegionDisabledException(inner),
201            crate::operation::assume_root::AssumeRootError::Unhandled(inner) => Error::Unhandled(inner),
202        }
203    }
204}
205impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::decode_authorization_message::DecodeAuthorizationMessageError, R>>
206    for Error
207where
208    R: Send + Sync + std::fmt::Debug + 'static,
209{
210    fn from(
211        err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::decode_authorization_message::DecodeAuthorizationMessageError, R>,
212    ) -> Self {
213        match err {
214            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
215            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
216                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
217                source: err.into(),
218            }),
219        }
220    }
221}
222impl From<crate::operation::decode_authorization_message::DecodeAuthorizationMessageError> for Error {
223    fn from(err: crate::operation::decode_authorization_message::DecodeAuthorizationMessageError) -> Self {
224        match err {
225            crate::operation::decode_authorization_message::DecodeAuthorizationMessageError::InvalidAuthorizationMessageException(inner) => {
226                Error::InvalidAuthorizationMessageException(inner)
227            }
228            crate::operation::decode_authorization_message::DecodeAuthorizationMessageError::Unhandled(inner) => Error::Unhandled(inner),
229        }
230    }
231}
232impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::get_access_key_info::GetAccessKeyInfoError, R>> for Error
233where
234    R: Send + Sync + std::fmt::Debug + 'static,
235{
236    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::get_access_key_info::GetAccessKeyInfoError, R>) -> Self {
237        match err {
238            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
239            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
240                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
241                source: err.into(),
242            }),
243        }
244    }
245}
246impl From<crate::operation::get_access_key_info::GetAccessKeyInfoError> for Error {
247    fn from(err: crate::operation::get_access_key_info::GetAccessKeyInfoError) -> Self {
248        match err {
249            crate::operation::get_access_key_info::GetAccessKeyInfoError::Unhandled(inner) => Error::Unhandled(inner),
250        }
251    }
252}
253impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::get_caller_identity::GetCallerIdentityError, R>> for Error
254where
255    R: Send + Sync + std::fmt::Debug + 'static,
256{
257    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::get_caller_identity::GetCallerIdentityError, R>) -> Self {
258        match err {
259            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
260            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
261                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
262                source: err.into(),
263            }),
264        }
265    }
266}
267impl From<crate::operation::get_caller_identity::GetCallerIdentityError> for Error {
268    fn from(err: crate::operation::get_caller_identity::GetCallerIdentityError) -> Self {
269        match err {
270            crate::operation::get_caller_identity::GetCallerIdentityError::Unhandled(inner) => Error::Unhandled(inner),
271        }
272    }
273}
274impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::get_federation_token::GetFederationTokenError, R>> for Error
275where
276    R: Send + Sync + std::fmt::Debug + 'static,
277{
278    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::get_federation_token::GetFederationTokenError, R>) -> Self {
279        match err {
280            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
281            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
282                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
283                source: err.into(),
284            }),
285        }
286    }
287}
288impl From<crate::operation::get_federation_token::GetFederationTokenError> for Error {
289    fn from(err: crate::operation::get_federation_token::GetFederationTokenError) -> Self {
290        match err {
291            crate::operation::get_federation_token::GetFederationTokenError::MalformedPolicyDocumentException(inner) => {
292                Error::MalformedPolicyDocumentException(inner)
293            }
294            crate::operation::get_federation_token::GetFederationTokenError::PackedPolicyTooLargeException(inner) => {
295                Error::PackedPolicyTooLargeException(inner)
296            }
297            crate::operation::get_federation_token::GetFederationTokenError::RegionDisabledException(inner) => Error::RegionDisabledException(inner),
298            crate::operation::get_federation_token::GetFederationTokenError::Unhandled(inner) => Error::Unhandled(inner),
299        }
300    }
301}
302impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::get_session_token::GetSessionTokenError, R>> for Error
303where
304    R: Send + Sync + std::fmt::Debug + 'static,
305{
306    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::get_session_token::GetSessionTokenError, R>) -> Self {
307        match err {
308            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
309            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
310                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
311                source: err.into(),
312            }),
313        }
314    }
315}
316impl From<crate::operation::get_session_token::GetSessionTokenError> for Error {
317    fn from(err: crate::operation::get_session_token::GetSessionTokenError) -> Self {
318        match err {
319            crate::operation::get_session_token::GetSessionTokenError::RegionDisabledException(inner) => Error::RegionDisabledException(inner),
320            crate::operation::get_session_token::GetSessionTokenError::Unhandled(inner) => Error::Unhandled(inner),
321        }
322    }
323}
324impl ::std::error::Error for Error {
325    fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
326        match self {
327            Error::ExpiredTokenException(inner) => inner.source(),
328            Error::IdpCommunicationErrorException(inner) => inner.source(),
329            Error::IdpRejectedClaimException(inner) => inner.source(),
330            Error::InvalidAuthorizationMessageException(inner) => inner.source(),
331            Error::InvalidIdentityTokenException(inner) => inner.source(),
332            Error::MalformedPolicyDocumentException(inner) => inner.source(),
333            Error::PackedPolicyTooLargeException(inner) => inner.source(),
334            Error::RegionDisabledException(inner) => inner.source(),
335            Error::Unhandled(inner) => ::std::option::Option::Some(&*inner.source),
336        }
337    }
338}
339impl ::aws_types::request_id::RequestId for Error {
340    fn request_id(&self) -> Option<&str> {
341        match self {
342            Self::ExpiredTokenException(e) => e.request_id(),
343            Self::IdpCommunicationErrorException(e) => e.request_id(),
344            Self::IdpRejectedClaimException(e) => e.request_id(),
345            Self::InvalidAuthorizationMessageException(e) => e.request_id(),
346            Self::InvalidIdentityTokenException(e) => e.request_id(),
347            Self::MalformedPolicyDocumentException(e) => e.request_id(),
348            Self::PackedPolicyTooLargeException(e) => e.request_id(),
349            Self::RegionDisabledException(e) => e.request_id(),
350            Self::Unhandled(e) => e.meta.request_id(),
351        }
352    }
353}