aws_sdk_costoptimizationhub/
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 not authorized to use this operation with the given parameters.</p>
7    AccessDeniedException(crate::types::error::AccessDeniedException),
8    /// <p>An error on the server occurred during the processing of your request. Try again later.</p>
9    InternalServerException(crate::types::error::InternalServerException),
10    /// <p>The specified Amazon Resource Name (ARN) in the request doesn't exist.</p>
11    ResourceNotFoundException(crate::types::error::ResourceNotFoundException),
12    /// <p>The request was denied due to request throttling.</p>
13    ThrottlingException(crate::types::error::ThrottlingException),
14    /// <p>The input fails to satisfy the constraints specified by an Amazon Web Services service.</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::ResourceNotFoundException(inner) => inner.fmt(f),
31            Error::ThrottlingException(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::ResourceNotFoundException(inner) => inner.meta(),
57            Self::ThrottlingException(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_preferences::GetPreferencesError, 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_preferences::GetPreferencesError, 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_preferences::GetPreferencesError> for Error {
78    fn from(err: crate::operation::get_preferences::GetPreferencesError) -> Self {
79        match err {
80            crate::operation::get_preferences::GetPreferencesError::AccessDeniedException(inner) => Error::AccessDeniedException(inner),
81            crate::operation::get_preferences::GetPreferencesError::InternalServerException(inner) => Error::InternalServerException(inner),
82            crate::operation::get_preferences::GetPreferencesError::ThrottlingException(inner) => Error::ThrottlingException(inner),
83            crate::operation::get_preferences::GetPreferencesError::ValidationException(inner) => Error::ValidationException(inner),
84            crate::operation::get_preferences::GetPreferencesError::Unhandled(inner) => Error::Unhandled(inner),
85        }
86    }
87}
88impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::get_recommendation::GetRecommendationError, 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::get_recommendation::GetRecommendationError, 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::get_recommendation::GetRecommendationError> for Error {
103    fn from(err: crate::operation::get_recommendation::GetRecommendationError) -> Self {
104        match err {
105            crate::operation::get_recommendation::GetRecommendationError::AccessDeniedException(inner) => Error::AccessDeniedException(inner),
106            crate::operation::get_recommendation::GetRecommendationError::InternalServerException(inner) => Error::InternalServerException(inner),
107            crate::operation::get_recommendation::GetRecommendationError::ResourceNotFoundException(inner) => Error::ResourceNotFoundException(inner),
108            crate::operation::get_recommendation::GetRecommendationError::ThrottlingException(inner) => Error::ThrottlingException(inner),
109            crate::operation::get_recommendation::GetRecommendationError::ValidationException(inner) => Error::ValidationException(inner),
110            crate::operation::get_recommendation::GetRecommendationError::Unhandled(inner) => Error::Unhandled(inner),
111        }
112    }
113}
114impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::list_enrollment_statuses::ListEnrollmentStatusesError, R>> for Error
115where
116    R: Send + Sync + std::fmt::Debug + 'static,
117{
118    fn from(
119        err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::list_enrollment_statuses::ListEnrollmentStatusesError, R>,
120    ) -> Self {
121        match err {
122            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
123            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
124                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
125                source: err.into(),
126            }),
127        }
128    }
129}
130impl From<crate::operation::list_enrollment_statuses::ListEnrollmentStatusesError> for Error {
131    fn from(err: crate::operation::list_enrollment_statuses::ListEnrollmentStatusesError) -> Self {
132        match err {
133            crate::operation::list_enrollment_statuses::ListEnrollmentStatusesError::AccessDeniedException(inner) => {
134                Error::AccessDeniedException(inner)
135            }
136            crate::operation::list_enrollment_statuses::ListEnrollmentStatusesError::InternalServerException(inner) => {
137                Error::InternalServerException(inner)
138            }
139            crate::operation::list_enrollment_statuses::ListEnrollmentStatusesError::ThrottlingException(inner) => Error::ThrottlingException(inner),
140            crate::operation::list_enrollment_statuses::ListEnrollmentStatusesError::ValidationException(inner) => Error::ValidationException(inner),
141            crate::operation::list_enrollment_statuses::ListEnrollmentStatusesError::Unhandled(inner) => Error::Unhandled(inner),
142        }
143    }
144}
145impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::list_recommendations::ListRecommendationsError, R>> for Error
146where
147    R: Send + Sync + std::fmt::Debug + 'static,
148{
149    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::list_recommendations::ListRecommendationsError, R>) -> Self {
150        match err {
151            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
152            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
153                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
154                source: err.into(),
155            }),
156        }
157    }
158}
159impl From<crate::operation::list_recommendations::ListRecommendationsError> for Error {
160    fn from(err: crate::operation::list_recommendations::ListRecommendationsError) -> Self {
161        match err {
162            crate::operation::list_recommendations::ListRecommendationsError::AccessDeniedException(inner) => Error::AccessDeniedException(inner),
163            crate::operation::list_recommendations::ListRecommendationsError::InternalServerException(inner) => Error::InternalServerException(inner),
164            crate::operation::list_recommendations::ListRecommendationsError::ThrottlingException(inner) => Error::ThrottlingException(inner),
165            crate::operation::list_recommendations::ListRecommendationsError::ValidationException(inner) => Error::ValidationException(inner),
166            crate::operation::list_recommendations::ListRecommendationsError::Unhandled(inner) => Error::Unhandled(inner),
167        }
168    }
169}
170impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::list_recommendation_summaries::ListRecommendationSummariesError, R>>
171    for Error
172where
173    R: Send + Sync + std::fmt::Debug + 'static,
174{
175    fn from(
176        err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::list_recommendation_summaries::ListRecommendationSummariesError, R>,
177    ) -> Self {
178        match err {
179            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
180            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
181                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
182                source: err.into(),
183            }),
184        }
185    }
186}
187impl From<crate::operation::list_recommendation_summaries::ListRecommendationSummariesError> for Error {
188    fn from(err: crate::operation::list_recommendation_summaries::ListRecommendationSummariesError) -> Self {
189        match err {
190            crate::operation::list_recommendation_summaries::ListRecommendationSummariesError::AccessDeniedException(inner) => {
191                Error::AccessDeniedException(inner)
192            }
193            crate::operation::list_recommendation_summaries::ListRecommendationSummariesError::InternalServerException(inner) => {
194                Error::InternalServerException(inner)
195            }
196            crate::operation::list_recommendation_summaries::ListRecommendationSummariesError::ThrottlingException(inner) => {
197                Error::ThrottlingException(inner)
198            }
199            crate::operation::list_recommendation_summaries::ListRecommendationSummariesError::ValidationException(inner) => {
200                Error::ValidationException(inner)
201            }
202            crate::operation::list_recommendation_summaries::ListRecommendationSummariesError::Unhandled(inner) => Error::Unhandled(inner),
203        }
204    }
205}
206impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::update_enrollment_status::UpdateEnrollmentStatusError, R>> 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::update_enrollment_status::UpdateEnrollmentStatusError, 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::update_enrollment_status::UpdateEnrollmentStatusError> for Error {
223    fn from(err: crate::operation::update_enrollment_status::UpdateEnrollmentStatusError) -> Self {
224        match err {
225            crate::operation::update_enrollment_status::UpdateEnrollmentStatusError::AccessDeniedException(inner) => {
226                Error::AccessDeniedException(inner)
227            }
228            crate::operation::update_enrollment_status::UpdateEnrollmentStatusError::InternalServerException(inner) => {
229                Error::InternalServerException(inner)
230            }
231            crate::operation::update_enrollment_status::UpdateEnrollmentStatusError::ThrottlingException(inner) => Error::ThrottlingException(inner),
232            crate::operation::update_enrollment_status::UpdateEnrollmentStatusError::ValidationException(inner) => Error::ValidationException(inner),
233            crate::operation::update_enrollment_status::UpdateEnrollmentStatusError::Unhandled(inner) => Error::Unhandled(inner),
234        }
235    }
236}
237impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::update_preferences::UpdatePreferencesError, R>> for Error
238where
239    R: Send + Sync + std::fmt::Debug + 'static,
240{
241    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::update_preferences::UpdatePreferencesError, R>) -> Self {
242        match err {
243            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
244            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
245                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
246                source: err.into(),
247            }),
248        }
249    }
250}
251impl From<crate::operation::update_preferences::UpdatePreferencesError> for Error {
252    fn from(err: crate::operation::update_preferences::UpdatePreferencesError) -> Self {
253        match err {
254            crate::operation::update_preferences::UpdatePreferencesError::AccessDeniedException(inner) => Error::AccessDeniedException(inner),
255            crate::operation::update_preferences::UpdatePreferencesError::InternalServerException(inner) => Error::InternalServerException(inner),
256            crate::operation::update_preferences::UpdatePreferencesError::ThrottlingException(inner) => Error::ThrottlingException(inner),
257            crate::operation::update_preferences::UpdatePreferencesError::ValidationException(inner) => Error::ValidationException(inner),
258            crate::operation::update_preferences::UpdatePreferencesError::Unhandled(inner) => Error::Unhandled(inner),
259        }
260    }
261}
262impl ::std::error::Error for Error {
263    fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
264        match self {
265            Error::AccessDeniedException(inner) => inner.source(),
266            Error::InternalServerException(inner) => inner.source(),
267            Error::ResourceNotFoundException(inner) => inner.source(),
268            Error::ThrottlingException(inner) => inner.source(),
269            Error::ValidationException(inner) => inner.source(),
270            Error::Unhandled(inner) => ::std::option::Option::Some(&*inner.source),
271        }
272    }
273}
274impl ::aws_types::request_id::RequestId for Error {
275    fn request_id(&self) -> Option<&str> {
276        match self {
277            Self::AccessDeniedException(e) => e.request_id(),
278            Self::InternalServerException(e) => e.request_id(),
279            Self::ResourceNotFoundException(e) => e.request_id(),
280            Self::ThrottlingException(e) => e.request_id(),
281            Self::ValidationException(e) => e.request_id(),
282            Self::Unhandled(e) => e.meta.request_id(),
283        }
284    }
285}