aws_sdk_sso/
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>Indicates that a problem occurred with the input to the request. For example, a required parameter might be missing or out of range.</p>
7    InvalidRequestException(crate::types::error::InvalidRequestException),
8    /// <p>The specified resource doesn't exist.</p>
9    ResourceNotFoundException(crate::types::error::ResourceNotFoundException),
10    /// <p>Indicates that the request is being made too frequently and is more than what the server can handle.</p>
11    TooManyRequestsException(crate::types::error::TooManyRequestsException),
12    /// <p>Indicates that the request is not authorized. This can happen due to an invalid access token in the request.</p>
13    UnauthorizedException(crate::types::error::UnauthorizedException),
14    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
15    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
16    variable wildcard pattern and check `.code()`:
17     \
18    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
19     \
20    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-Error) for what information is available for the error.")]
21    Unhandled(crate::error::sealed_unhandled::Unhandled),
22}
23impl ::std::fmt::Display for Error {
24    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25        match self {
26            Error::InvalidRequestException(inner) => inner.fmt(f),
27            Error::ResourceNotFoundException(inner) => inner.fmt(f),
28            Error::TooManyRequestsException(inner) => inner.fmt(f),
29            Error::UnauthorizedException(inner) => inner.fmt(f),
30            Error::Unhandled(_) => {
31                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
32                    write!(f, "unhandled error ({code})")
33                } else {
34                    f.write_str("unhandled error")
35                }
36            }
37        }
38    }
39}
40impl From<::aws_smithy_types::error::operation::BuildError> for Error {
41    fn from(value: ::aws_smithy_types::error::operation::BuildError) -> Self {
42        Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
43            source: value.into(),
44            meta: ::std::default::Default::default(),
45        })
46    }
47}
48impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for Error {
49    fn meta(&self) -> &::aws_smithy_types::error::metadata::ErrorMetadata {
50        match self {
51            Self::InvalidRequestException(inner) => inner.meta(),
52            Self::ResourceNotFoundException(inner) => inner.meta(),
53            Self::TooManyRequestsException(inner) => inner.meta(),
54            Self::UnauthorizedException(inner) => inner.meta(),
55            Self::Unhandled(inner) => &inner.meta,
56        }
57    }
58}
59impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::get_role_credentials::GetRoleCredentialsError, R>> for Error
60where
61    R: Send + Sync + std::fmt::Debug + 'static,
62{
63    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::get_role_credentials::GetRoleCredentialsError, R>) -> Self {
64        match err {
65            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
66            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
67                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
68                source: err.into(),
69            }),
70        }
71    }
72}
73impl From<crate::operation::get_role_credentials::GetRoleCredentialsError> for Error {
74    fn from(err: crate::operation::get_role_credentials::GetRoleCredentialsError) -> Self {
75        match err {
76            crate::operation::get_role_credentials::GetRoleCredentialsError::InvalidRequestException(inner) => Error::InvalidRequestException(inner),
77            crate::operation::get_role_credentials::GetRoleCredentialsError::ResourceNotFoundException(inner) => {
78                Error::ResourceNotFoundException(inner)
79            }
80            crate::operation::get_role_credentials::GetRoleCredentialsError::TooManyRequestsException(inner) => {
81                Error::TooManyRequestsException(inner)
82            }
83            crate::operation::get_role_credentials::GetRoleCredentialsError::UnauthorizedException(inner) => Error::UnauthorizedException(inner),
84            crate::operation::get_role_credentials::GetRoleCredentialsError::Unhandled(inner) => Error::Unhandled(inner),
85        }
86    }
87}
88impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::list_account_roles::ListAccountRolesError, R>> for Error
89where
90    R: Send + Sync + std::fmt::Debug + 'static,
91{
92    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::list_account_roles::ListAccountRolesError, R>) -> Self {
93        match err {
94            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
95            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
96                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
97                source: err.into(),
98            }),
99        }
100    }
101}
102impl From<crate::operation::list_account_roles::ListAccountRolesError> for Error {
103    fn from(err: crate::operation::list_account_roles::ListAccountRolesError) -> Self {
104        match err {
105            crate::operation::list_account_roles::ListAccountRolesError::InvalidRequestException(inner) => Error::InvalidRequestException(inner),
106            crate::operation::list_account_roles::ListAccountRolesError::ResourceNotFoundException(inner) => Error::ResourceNotFoundException(inner),
107            crate::operation::list_account_roles::ListAccountRolesError::TooManyRequestsException(inner) => Error::TooManyRequestsException(inner),
108            crate::operation::list_account_roles::ListAccountRolesError::UnauthorizedException(inner) => Error::UnauthorizedException(inner),
109            crate::operation::list_account_roles::ListAccountRolesError::Unhandled(inner) => Error::Unhandled(inner),
110        }
111    }
112}
113impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::list_accounts::ListAccountsError, R>> for Error
114where
115    R: Send + Sync + std::fmt::Debug + 'static,
116{
117    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::list_accounts::ListAccountsError, R>) -> Self {
118        match err {
119            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
120            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
121                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
122                source: err.into(),
123            }),
124        }
125    }
126}
127impl From<crate::operation::list_accounts::ListAccountsError> for Error {
128    fn from(err: crate::operation::list_accounts::ListAccountsError) -> Self {
129        match err {
130            crate::operation::list_accounts::ListAccountsError::InvalidRequestException(inner) => Error::InvalidRequestException(inner),
131            crate::operation::list_accounts::ListAccountsError::ResourceNotFoundException(inner) => Error::ResourceNotFoundException(inner),
132            crate::operation::list_accounts::ListAccountsError::TooManyRequestsException(inner) => Error::TooManyRequestsException(inner),
133            crate::operation::list_accounts::ListAccountsError::UnauthorizedException(inner) => Error::UnauthorizedException(inner),
134            crate::operation::list_accounts::ListAccountsError::Unhandled(inner) => Error::Unhandled(inner),
135        }
136    }
137}
138impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::logout::LogoutError, R>> for Error
139where
140    R: Send + Sync + std::fmt::Debug + 'static,
141{
142    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::logout::LogoutError, R>) -> Self {
143        match err {
144            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
145            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
146                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
147                source: err.into(),
148            }),
149        }
150    }
151}
152impl From<crate::operation::logout::LogoutError> for Error {
153    fn from(err: crate::operation::logout::LogoutError) -> Self {
154        match err {
155            crate::operation::logout::LogoutError::InvalidRequestException(inner) => Error::InvalidRequestException(inner),
156            crate::operation::logout::LogoutError::TooManyRequestsException(inner) => Error::TooManyRequestsException(inner),
157            crate::operation::logout::LogoutError::UnauthorizedException(inner) => Error::UnauthorizedException(inner),
158            crate::operation::logout::LogoutError::Unhandled(inner) => Error::Unhandled(inner),
159        }
160    }
161}
162impl ::std::error::Error for Error {
163    fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
164        match self {
165            Error::InvalidRequestException(inner) => inner.source(),
166            Error::ResourceNotFoundException(inner) => inner.source(),
167            Error::TooManyRequestsException(inner) => inner.source(),
168            Error::UnauthorizedException(inner) => inner.source(),
169            Error::Unhandled(inner) => ::std::option::Option::Some(&*inner.source),
170        }
171    }
172}
173impl ::aws_types::request_id::RequestId for Error {
174    fn request_id(&self) -> Option<&str> {
175        match self {
176            Self::InvalidRequestException(e) => e.request_id(),
177            Self::ResourceNotFoundException(e) => e.request_id(),
178            Self::TooManyRequestsException(e) => e.request_id(),
179            Self::UnauthorizedException(e) => e.request_id(),
180            Self::Unhandled(e) => e.meta.request_id(),
181        }
182    }
183}