aws_sdk_sso/
error_meta.rs1#[non_exhaustive]
4#[derive(::std::fmt::Debug)]
5pub enum Error {
6 InvalidRequestException(crate::types::error::InvalidRequestException),
8 ResourceNotFoundException(crate::types::error::ResourceNotFoundException),
10 TooManyRequestsException(crate::types::error::TooManyRequestsException),
12 UnauthorizedException(crate::types::error::UnauthorizedException),
14 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
16 variable wildcard pattern and check `.code()`:
17 \
18 `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(_) => if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
31 write!(f, "unhandled error ({code})")
32 } else {
33 f.write_str("unhandled error")
34 }
35 }
36 }
37}
38impl From<::aws_smithy_types::error::operation::BuildError> for Error {
39 fn from(value: ::aws_smithy_types::error::operation::BuildError) -> Self {
40 Error::Unhandled(crate::error::sealed_unhandled::Unhandled { source: value.into(), meta: ::std::default::Default::default() })
41 }
42 }
43impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for Error {
44 fn meta(&self) -> &::aws_smithy_types::error::metadata::ErrorMetadata {
45 match self {
46 Self::InvalidRequestException(inner) => inner.meta(),
47Self::ResourceNotFoundException(inner) => inner.meta(),
48Self::TooManyRequestsException(inner) => inner.meta(),
49Self::UnauthorizedException(inner) => inner.meta(),
50 Self::Unhandled(inner) => &inner.meta,
51 }
52 }
53 }
54impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::get_role_credentials::GetRoleCredentialsError, R>> for Error where R: Send + Sync + std::fmt::Debug + 'static {
55 fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::get_role_credentials::GetRoleCredentialsError, R>) -> Self {
56 match err {
57 ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
58 _ => Error::Unhandled(
59 crate::error::sealed_unhandled::Unhandled {
60 meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
61 source: err.into(),
62 }
63 ),
64 }
65 }
66}
67impl From<crate::operation::get_role_credentials::GetRoleCredentialsError> for Error {
68 fn from(err: crate::operation::get_role_credentials::GetRoleCredentialsError) -> Self {
69 match err {
70 crate::operation::get_role_credentials::GetRoleCredentialsError::InvalidRequestException(inner) => Error::InvalidRequestException(inner),
71 crate::operation::get_role_credentials::GetRoleCredentialsError::ResourceNotFoundException(inner) => Error::ResourceNotFoundException(inner),
72 crate::operation::get_role_credentials::GetRoleCredentialsError::TooManyRequestsException(inner) => Error::TooManyRequestsException(inner),
73 crate::operation::get_role_credentials::GetRoleCredentialsError::UnauthorizedException(inner) => Error::UnauthorizedException(inner),
74 crate::operation::get_role_credentials::GetRoleCredentialsError::Unhandled(inner) => Error::Unhandled(inner),
75 }
76 }
77}
78impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::list_account_roles::ListAccountRolesError, R>> for Error where R: Send + Sync + std::fmt::Debug + 'static {
79 fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::list_account_roles::ListAccountRolesError, R>) -> Self {
80 match err {
81 ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
82 _ => Error::Unhandled(
83 crate::error::sealed_unhandled::Unhandled {
84 meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
85 source: err.into(),
86 }
87 ),
88 }
89 }
90}
91impl From<crate::operation::list_account_roles::ListAccountRolesError> for Error {
92 fn from(err: crate::operation::list_account_roles::ListAccountRolesError) -> Self {
93 match err {
94 crate::operation::list_account_roles::ListAccountRolesError::InvalidRequestException(inner) => Error::InvalidRequestException(inner),
95 crate::operation::list_account_roles::ListAccountRolesError::ResourceNotFoundException(inner) => Error::ResourceNotFoundException(inner),
96 crate::operation::list_account_roles::ListAccountRolesError::TooManyRequestsException(inner) => Error::TooManyRequestsException(inner),
97 crate::operation::list_account_roles::ListAccountRolesError::UnauthorizedException(inner) => Error::UnauthorizedException(inner),
98 crate::operation::list_account_roles::ListAccountRolesError::Unhandled(inner) => Error::Unhandled(inner),
99 }
100 }
101}
102impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::list_accounts::ListAccountsError, R>> for Error where R: Send + Sync + std::fmt::Debug + 'static {
103 fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::list_accounts::ListAccountsError, R>) -> Self {
104 match err {
105 ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
106 _ => Error::Unhandled(
107 crate::error::sealed_unhandled::Unhandled {
108 meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
109 source: err.into(),
110 }
111 ),
112 }
113 }
114}
115impl From<crate::operation::list_accounts::ListAccountsError> for Error {
116 fn from(err: crate::operation::list_accounts::ListAccountsError) -> Self {
117 match err {
118 crate::operation::list_accounts::ListAccountsError::InvalidRequestException(inner) => Error::InvalidRequestException(inner),
119 crate::operation::list_accounts::ListAccountsError::ResourceNotFoundException(inner) => Error::ResourceNotFoundException(inner),
120 crate::operation::list_accounts::ListAccountsError::TooManyRequestsException(inner) => Error::TooManyRequestsException(inner),
121 crate::operation::list_accounts::ListAccountsError::UnauthorizedException(inner) => Error::UnauthorizedException(inner),
122 crate::operation::list_accounts::ListAccountsError::Unhandled(inner) => Error::Unhandled(inner),
123 }
124 }
125}
126impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::logout::LogoutError, R>> for Error where R: Send + Sync + std::fmt::Debug + 'static {
127 fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::logout::LogoutError, R>) -> Self {
128 match err {
129 ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
130 _ => Error::Unhandled(
131 crate::error::sealed_unhandled::Unhandled {
132 meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
133 source: err.into(),
134 }
135 ),
136 }
137 }
138}
139impl From<crate::operation::logout::LogoutError> for Error {
140 fn from(err: crate::operation::logout::LogoutError) -> Self {
141 match err {
142 crate::operation::logout::LogoutError::InvalidRequestException(inner) => Error::InvalidRequestException(inner),
143 crate::operation::logout::LogoutError::TooManyRequestsException(inner) => Error::TooManyRequestsException(inner),
144 crate::operation::logout::LogoutError::UnauthorizedException(inner) => Error::UnauthorizedException(inner),
145 crate::operation::logout::LogoutError::Unhandled(inner) => Error::Unhandled(inner),
146 }
147 }
148}
149impl ::std::error::Error for Error {
150 fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
151 match self {
152 Error::InvalidRequestException(inner) => inner.source(),
153 Error::ResourceNotFoundException(inner) => inner.source(),
154 Error::TooManyRequestsException(inner) => inner.source(),
155 Error::UnauthorizedException(inner) => inner.source(),
156 Error::Unhandled(inner) => ::std::option::Option::Some(&*inner.source)
157 }
158 }
159}
160impl ::aws_types::request_id::RequestId for Error {
161 fn request_id(&self) -> Option<&str> {
162 match self {
163 Self::InvalidRequestException(e) => e.request_id(),
164 Self::ResourceNotFoundException(e) => e.request_id(),
165 Self::TooManyRequestsException(e) => e.request_id(),
166 Self::UnauthorizedException(e) => e.request_id(),
167 Self::Unhandled(e) => e.meta.request_id(),
168 }
169 }
170}
171