Skip to main content

aws_sdk_accountaccessruntime/
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>You are authenticated but not authorized to perform the requested action, such as assuming a role that you aren't entitled to. This error returns an HTTP 403 status code.</p>
7    AccessDeniedException(crate::types::error::AccessDeniedException),
8    /// <p>An internal server error occurred. Retry the request. If the problem persists, contact Amazon Web Services Support. This error returns an HTTP 500 status code.</p>
9    InternalServerException(crate::types::error::InternalServerException),
10    /// <p>The request rate exceeded the allowed limit. Reduce your request rate, and then retry the request. This error returns an HTTP 429 status code.</p>
11    ThrottlingException(crate::types::error::ThrottlingException),
12    /// <p>The bearer token is missing, invalid, or expired. Obtain a new token, and then retry the request. This error returns an HTTP 401 status code.</p>
13    UnauthorizedException(crate::types::error::UnauthorizedException),
14    /// <p>The request is missing a required parameter, or a parameter value doesn't satisfy its constraints, such as its length or pattern. Correct the input, and then retry the request. This error returns an HTTP 400 status code.</p>
15    ValidationException(crate::types::error::ValidationException),
16    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
17    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
18    variable wildcard pattern and check `.code()`:
19     \
20    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
21     \
22    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-Error) for what information is available for the error.")]
23    Unhandled(crate::error::sealed_unhandled::Unhandled),
24}
25impl ::std::fmt::Display for Error {
26    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
27        match self {
28            Error::AccessDeniedException(inner) => inner.fmt(f),
29            Error::InternalServerException(inner) => inner.fmt(f),
30            Error::ThrottlingException(inner) => inner.fmt(f),
31            Error::UnauthorizedException(inner) => inner.fmt(f),
32            Error::ValidationException(inner) => inner.fmt(f),
33            Error::Unhandled(_) => {
34                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
35                    write!(f, "unhandled error ({code})")
36                } else {
37                    f.write_str("unhandled error")
38                }
39            }
40        }
41    }
42}
43impl From<::aws_smithy_types::error::operation::BuildError> for Error {
44    fn from(value: ::aws_smithy_types::error::operation::BuildError) -> Self {
45        Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
46            source: value.into(),
47            meta: ::std::default::Default::default(),
48        })
49    }
50}
51impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for Error {
52    fn meta(&self) -> &::aws_smithy_types::error::metadata::ErrorMetadata {
53        match self {
54            Self::AccessDeniedException(inner) => inner.meta(),
55            Self::InternalServerException(inner) => inner.meta(),
56            Self::ThrottlingException(inner) => inner.meta(),
57            Self::UnauthorizedException(inner) => inner.meta(),
58            Self::ValidationException(inner) => inner.meta(),
59            Self::Unhandled(inner) => &inner.meta,
60        }
61    }
62}
63impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::get_role_credentials::GetRoleCredentialsError, R>> for Error
64where
65    R: Send + Sync + std::fmt::Debug + 'static,
66{
67    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::get_role_credentials::GetRoleCredentialsError, R>) -> Self {
68        match err {
69            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
70            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
71                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
72                source: err.into(),
73            }),
74        }
75    }
76}
77impl From<crate::operation::get_role_credentials::GetRoleCredentialsError> for Error {
78    fn from(err: crate::operation::get_role_credentials::GetRoleCredentialsError) -> Self {
79        match err {
80            crate::operation::get_role_credentials::GetRoleCredentialsError::AccessDeniedException(inner) => Error::AccessDeniedException(inner),
81            crate::operation::get_role_credentials::GetRoleCredentialsError::InternalServerException(inner) => Error::InternalServerException(inner),
82            crate::operation::get_role_credentials::GetRoleCredentialsError::ThrottlingException(inner) => Error::ThrottlingException(inner),
83            crate::operation::get_role_credentials::GetRoleCredentialsError::UnauthorizedException(inner) => Error::UnauthorizedException(inner),
84            crate::operation::get_role_credentials::GetRoleCredentialsError::ValidationException(inner) => Error::ValidationException(inner),
85            crate::operation::get_role_credentials::GetRoleCredentialsError::Unhandled(inner) => Error::Unhandled(inner),
86        }
87    }
88}
89impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::list_roles::ListRolesError, R>> for Error
90where
91    R: Send + Sync + std::fmt::Debug + 'static,
92{
93    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::list_roles::ListRolesError, R>) -> Self {
94        match err {
95            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
96            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
97                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
98                source: err.into(),
99            }),
100        }
101    }
102}
103impl From<crate::operation::list_roles::ListRolesError> for Error {
104    fn from(err: crate::operation::list_roles::ListRolesError) -> Self {
105        match err {
106            crate::operation::list_roles::ListRolesError::InternalServerException(inner) => Error::InternalServerException(inner),
107            crate::operation::list_roles::ListRolesError::ThrottlingException(inner) => Error::ThrottlingException(inner),
108            crate::operation::list_roles::ListRolesError::UnauthorizedException(inner) => Error::UnauthorizedException(inner),
109            crate::operation::list_roles::ListRolesError::ValidationException(inner) => Error::ValidationException(inner),
110            crate::operation::list_roles::ListRolesError::Unhandled(inner) => Error::Unhandled(inner),
111        }
112    }
113}
114impl ::std::error::Error for Error {
115    fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
116        match self {
117            Error::AccessDeniedException(inner) => inner.source(),
118            Error::InternalServerException(inner) => inner.source(),
119            Error::ThrottlingException(inner) => inner.source(),
120            Error::UnauthorizedException(inner) => inner.source(),
121            Error::ValidationException(inner) => inner.source(),
122            Error::Unhandled(inner) => ::std::option::Option::Some(&*inner.source),
123        }
124    }
125}
126impl ::aws_types::request_id::RequestId for Error {
127    fn request_id(&self) -> Option<&str> {
128        match self {
129            Self::AccessDeniedException(e) => e.request_id(),
130            Self::InternalServerException(e) => e.request_id(),
131            Self::ThrottlingException(e) => e.request_id(),
132            Self::UnauthorizedException(e) => e.request_id(),
133            Self::ValidationException(e) => e.request_id(),
134            Self::Unhandled(e) => e.meta.request_id(),
135        }
136    }
137}