1#[non_exhaustive]
4#[derive(::std::fmt::Debug)]
5pub enum Error {
6    InternalServerException(crate::types::error::InternalServerException),
8    ResourceNotFoundException(crate::types::error::ResourceNotFoundException),
10    ServiceQuotaExceededException(crate::types::error::ServiceQuotaExceededException),
12    ValidationException(crate::types::error::ValidationException),
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::InternalServerException(inner) => inner.fmt(f),
27            Error::ResourceNotFoundException(inner) => inner.fmt(f),
28            Error::ServiceQuotaExceededException(inner) => inner.fmt(f),
29            Error::ValidationException(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::InternalServerException(inner) => inner.meta(),
52            Self::ResourceNotFoundException(inner) => inner.meta(),
53            Self::ServiceQuotaExceededException(inner) => inner.meta(),
54            Self::ValidationException(inner) => inner.meta(),
55            Self::Unhandled(inner) => &inner.meta,
56        }
57    }
58}
59impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::create_savings_plan::CreateSavingsPlanError, 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::create_savings_plan::CreateSavingsPlanError, 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::create_savings_plan::CreateSavingsPlanError> for Error {
74    fn from(err: crate::operation::create_savings_plan::CreateSavingsPlanError) -> Self {
75        match err {
76            crate::operation::create_savings_plan::CreateSavingsPlanError::InternalServerException(inner) => Error::InternalServerException(inner),
77            crate::operation::create_savings_plan::CreateSavingsPlanError::ResourceNotFoundException(inner) => {
78                Error::ResourceNotFoundException(inner)
79            }
80            crate::operation::create_savings_plan::CreateSavingsPlanError::ServiceQuotaExceededException(inner) => {
81                Error::ServiceQuotaExceededException(inner)
82            }
83            crate::operation::create_savings_plan::CreateSavingsPlanError::ValidationException(inner) => Error::ValidationException(inner),
84            crate::operation::create_savings_plan::CreateSavingsPlanError::Unhandled(inner) => Error::Unhandled(inner),
85        }
86    }
87}
88impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::delete_queued_savings_plan::DeleteQueuedSavingsPlanError, R>>
89    for Error
90where
91    R: Send + Sync + std::fmt::Debug + 'static,
92{
93    fn from(
94        err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::delete_queued_savings_plan::DeleteQueuedSavingsPlanError, R>,
95    ) -> Self {
96        match err {
97            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
98            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
99                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
100                source: err.into(),
101            }),
102        }
103    }
104}
105impl From<crate::operation::delete_queued_savings_plan::DeleteQueuedSavingsPlanError> for Error {
106    fn from(err: crate::operation::delete_queued_savings_plan::DeleteQueuedSavingsPlanError) -> Self {
107        match err {
108            crate::operation::delete_queued_savings_plan::DeleteQueuedSavingsPlanError::InternalServerException(inner) => {
109                Error::InternalServerException(inner)
110            }
111            crate::operation::delete_queued_savings_plan::DeleteQueuedSavingsPlanError::ResourceNotFoundException(inner) => {
112                Error::ResourceNotFoundException(inner)
113            }
114            crate::operation::delete_queued_savings_plan::DeleteQueuedSavingsPlanError::ServiceQuotaExceededException(inner) => {
115                Error::ServiceQuotaExceededException(inner)
116            }
117            crate::operation::delete_queued_savings_plan::DeleteQueuedSavingsPlanError::ValidationException(inner) => {
118                Error::ValidationException(inner)
119            }
120            crate::operation::delete_queued_savings_plan::DeleteQueuedSavingsPlanError::Unhandled(inner) => Error::Unhandled(inner),
121        }
122    }
123}
124impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::describe_savings_plan_rates::DescribeSavingsPlanRatesError, R>>
125    for Error
126where
127    R: Send + Sync + std::fmt::Debug + 'static,
128{
129    fn from(
130        err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::describe_savings_plan_rates::DescribeSavingsPlanRatesError, R>,
131    ) -> Self {
132        match err {
133            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
134            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
135                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
136                source: err.into(),
137            }),
138        }
139    }
140}
141impl From<crate::operation::describe_savings_plan_rates::DescribeSavingsPlanRatesError> for Error {
142    fn from(err: crate::operation::describe_savings_plan_rates::DescribeSavingsPlanRatesError) -> Self {
143        match err {
144            crate::operation::describe_savings_plan_rates::DescribeSavingsPlanRatesError::ResourceNotFoundException(inner) => {
145                Error::ResourceNotFoundException(inner)
146            }
147            crate::operation::describe_savings_plan_rates::DescribeSavingsPlanRatesError::ValidationException(inner) => {
148                Error::ValidationException(inner)
149            }
150            crate::operation::describe_savings_plan_rates::DescribeSavingsPlanRatesError::Unhandled(inner) => Error::Unhandled(inner),
151        }
152    }
153}
154impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::describe_savings_plans::DescribeSavingsPlansError, R>> for Error
155where
156    R: Send + Sync + std::fmt::Debug + 'static,
157{
158    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::describe_savings_plans::DescribeSavingsPlansError, R>) -> Self {
159        match err {
160            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
161            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
162                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
163                source: err.into(),
164            }),
165        }
166    }
167}
168impl From<crate::operation::describe_savings_plans::DescribeSavingsPlansError> for Error {
169    fn from(err: crate::operation::describe_savings_plans::DescribeSavingsPlansError) -> Self {
170        match err {
171            crate::operation::describe_savings_plans::DescribeSavingsPlansError::InternalServerException(inner) => {
172                Error::InternalServerException(inner)
173            }
174            crate::operation::describe_savings_plans::DescribeSavingsPlansError::ValidationException(inner) => Error::ValidationException(inner),
175            crate::operation::describe_savings_plans::DescribeSavingsPlansError::Unhandled(inner) => Error::Unhandled(inner),
176        }
177    }
178}
179impl<R>
180    From<
181        ::aws_smithy_runtime_api::client::result::SdkError<
182            crate::operation::describe_savings_plans_offering_rates::DescribeSavingsPlansOfferingRatesError,
183            R,
184        >,
185    > for Error
186where
187    R: Send + Sync + std::fmt::Debug + 'static,
188{
189    fn from(
190        err: ::aws_smithy_runtime_api::client::result::SdkError<
191            crate::operation::describe_savings_plans_offering_rates::DescribeSavingsPlansOfferingRatesError,
192            R,
193        >,
194    ) -> Self {
195        match err {
196            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
197            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
198                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
199                source: err.into(),
200            }),
201        }
202    }
203}
204impl From<crate::operation::describe_savings_plans_offering_rates::DescribeSavingsPlansOfferingRatesError> for Error {
205    fn from(err: crate::operation::describe_savings_plans_offering_rates::DescribeSavingsPlansOfferingRatesError) -> Self {
206        match err {
207            crate::operation::describe_savings_plans_offering_rates::DescribeSavingsPlansOfferingRatesError::InternalServerException(inner) => {
208                Error::InternalServerException(inner)
209            }
210            crate::operation::describe_savings_plans_offering_rates::DescribeSavingsPlansOfferingRatesError::ValidationException(inner) => {
211                Error::ValidationException(inner)
212            }
213            crate::operation::describe_savings_plans_offering_rates::DescribeSavingsPlansOfferingRatesError::Unhandled(inner) => {
214                Error::Unhandled(inner)
215            }
216        }
217    }
218}
219impl<R>
220    From<
221        ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::describe_savings_plans_offerings::DescribeSavingsPlansOfferingsError, R>,
222    > for Error
223where
224    R: Send + Sync + std::fmt::Debug + 'static,
225{
226    fn from(
227        err: ::aws_smithy_runtime_api::client::result::SdkError<
228            crate::operation::describe_savings_plans_offerings::DescribeSavingsPlansOfferingsError,
229            R,
230        >,
231    ) -> Self {
232        match err {
233            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
234            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
235                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
236                source: err.into(),
237            }),
238        }
239    }
240}
241impl From<crate::operation::describe_savings_plans_offerings::DescribeSavingsPlansOfferingsError> for Error {
242    fn from(err: crate::operation::describe_savings_plans_offerings::DescribeSavingsPlansOfferingsError) -> Self {
243        match err {
244            crate::operation::describe_savings_plans_offerings::DescribeSavingsPlansOfferingsError::InternalServerException(inner) => {
245                Error::InternalServerException(inner)
246            }
247            crate::operation::describe_savings_plans_offerings::DescribeSavingsPlansOfferingsError::ValidationException(inner) => {
248                Error::ValidationException(inner)
249            }
250            crate::operation::describe_savings_plans_offerings::DescribeSavingsPlansOfferingsError::Unhandled(inner) => Error::Unhandled(inner),
251        }
252    }
253}
254impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::list_tags_for_resource::ListTagsForResourceError, R>> for Error
255where
256    R: Send + Sync + std::fmt::Debug + 'static,
257{
258    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::list_tags_for_resource::ListTagsForResourceError, R>) -> Self {
259        match err {
260            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
261            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
262                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
263                source: err.into(),
264            }),
265        }
266    }
267}
268impl From<crate::operation::list_tags_for_resource::ListTagsForResourceError> for Error {
269    fn from(err: crate::operation::list_tags_for_resource::ListTagsForResourceError) -> Self {
270        match err {
271            crate::operation::list_tags_for_resource::ListTagsForResourceError::InternalServerException(inner) => {
272                Error::InternalServerException(inner)
273            }
274            crate::operation::list_tags_for_resource::ListTagsForResourceError::ResourceNotFoundException(inner) => {
275                Error::ResourceNotFoundException(inner)
276            }
277            crate::operation::list_tags_for_resource::ListTagsForResourceError::ValidationException(inner) => Error::ValidationException(inner),
278            crate::operation::list_tags_for_resource::ListTagsForResourceError::Unhandled(inner) => Error::Unhandled(inner),
279        }
280    }
281}
282impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::return_savings_plan::ReturnSavingsPlanError, R>> for Error
283where
284    R: Send + Sync + std::fmt::Debug + 'static,
285{
286    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::return_savings_plan::ReturnSavingsPlanError, R>) -> Self {
287        match err {
288            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
289            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
290                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
291                source: err.into(),
292            }),
293        }
294    }
295}
296impl From<crate::operation::return_savings_plan::ReturnSavingsPlanError> for Error {
297    fn from(err: crate::operation::return_savings_plan::ReturnSavingsPlanError) -> Self {
298        match err {
299            crate::operation::return_savings_plan::ReturnSavingsPlanError::InternalServerException(inner) => Error::InternalServerException(inner),
300            crate::operation::return_savings_plan::ReturnSavingsPlanError::ResourceNotFoundException(inner) => {
301                Error::ResourceNotFoundException(inner)
302            }
303            crate::operation::return_savings_plan::ReturnSavingsPlanError::ServiceQuotaExceededException(inner) => {
304                Error::ServiceQuotaExceededException(inner)
305            }
306            crate::operation::return_savings_plan::ReturnSavingsPlanError::ValidationException(inner) => Error::ValidationException(inner),
307            crate::operation::return_savings_plan::ReturnSavingsPlanError::Unhandled(inner) => Error::Unhandled(inner),
308        }
309    }
310}
311impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::tag_resource::TagResourceError, R>> for Error
312where
313    R: Send + Sync + std::fmt::Debug + 'static,
314{
315    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::tag_resource::TagResourceError, R>) -> Self {
316        match err {
317            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
318            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
319                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
320                source: err.into(),
321            }),
322        }
323    }
324}
325impl From<crate::operation::tag_resource::TagResourceError> for Error {
326    fn from(err: crate::operation::tag_resource::TagResourceError) -> Self {
327        match err {
328            crate::operation::tag_resource::TagResourceError::InternalServerException(inner) => Error::InternalServerException(inner),
329            crate::operation::tag_resource::TagResourceError::ResourceNotFoundException(inner) => Error::ResourceNotFoundException(inner),
330            crate::operation::tag_resource::TagResourceError::ServiceQuotaExceededException(inner) => Error::ServiceQuotaExceededException(inner),
331            crate::operation::tag_resource::TagResourceError::ValidationException(inner) => Error::ValidationException(inner),
332            crate::operation::tag_resource::TagResourceError::Unhandled(inner) => Error::Unhandled(inner),
333        }
334    }
335}
336impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::untag_resource::UntagResourceError, R>> for Error
337where
338    R: Send + Sync + std::fmt::Debug + 'static,
339{
340    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::untag_resource::UntagResourceError, R>) -> Self {
341        match err {
342            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
343            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
344                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
345                source: err.into(),
346            }),
347        }
348    }
349}
350impl From<crate::operation::untag_resource::UntagResourceError> for Error {
351    fn from(err: crate::operation::untag_resource::UntagResourceError) -> Self {
352        match err {
353            crate::operation::untag_resource::UntagResourceError::InternalServerException(inner) => Error::InternalServerException(inner),
354            crate::operation::untag_resource::UntagResourceError::ResourceNotFoundException(inner) => Error::ResourceNotFoundException(inner),
355            crate::operation::untag_resource::UntagResourceError::ValidationException(inner) => Error::ValidationException(inner),
356            crate::operation::untag_resource::UntagResourceError::Unhandled(inner) => Error::Unhandled(inner),
357        }
358    }
359}
360impl ::std::error::Error for Error {
361    fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
362        match self {
363            Error::InternalServerException(inner) => inner.source(),
364            Error::ResourceNotFoundException(inner) => inner.source(),
365            Error::ServiceQuotaExceededException(inner) => inner.source(),
366            Error::ValidationException(inner) => inner.source(),
367            Error::Unhandled(inner) => ::std::option::Option::Some(&*inner.source),
368        }
369    }
370}
371impl ::aws_types::request_id::RequestId for Error {
372    fn request_id(&self) -> Option<&str> {
373        match self {
374            Self::InternalServerException(e) => e.request_id(),
375            Self::ResourceNotFoundException(e) => e.request_id(),
376            Self::ServiceQuotaExceededException(e) => e.request_id(),
377            Self::ValidationException(e) => e.request_id(),
378            Self::Unhandled(e) => e.meta.request_id(),
379        }
380    }
381}