aws_sdk_elasticinference/
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>Raised when a malformed input has been provided to the API.</p>
7    BadRequestException(crate::types::error::BadRequestException),
8    /// <p>Raised when an unexpected error occurred during request processing.</p>
9    InternalServerException(crate::types::error::InternalServerException),
10    /// <p>Raised when the requested resource cannot be found.</p>
11    ResourceNotFoundException(crate::types::error::ResourceNotFoundException),
12    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
13    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
14    variable wildcard pattern and check `.code()`:
15     \
16    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
17     \
18    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-Error) for what information is available for the error.")]
19    Unhandled(crate::error::sealed_unhandled::Unhandled),
20}
21impl ::std::fmt::Display for Error {
22    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23        match self {
24            Error::BadRequestException(inner) => inner.fmt(f),
25            Error::InternalServerException(inner) => inner.fmt(f),
26            Error::ResourceNotFoundException(inner) => inner.fmt(f),
27            Error::Unhandled(_) => {
28                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
29                    write!(f, "unhandled error ({code})")
30                } else {
31                    f.write_str("unhandled error")
32                }
33            }
34        }
35    }
36}
37impl From<::aws_smithy_types::error::operation::BuildError> for Error {
38    fn from(value: ::aws_smithy_types::error::operation::BuildError) -> Self {
39        Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
40            source: value.into(),
41            meta: ::std::default::Default::default(),
42        })
43    }
44}
45impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for Error {
46    fn meta(&self) -> &::aws_smithy_types::error::metadata::ErrorMetadata {
47        match self {
48            Self::BadRequestException(inner) => inner.meta(),
49            Self::InternalServerException(inner) => inner.meta(),
50            Self::ResourceNotFoundException(inner) => inner.meta(),
51            Self::Unhandled(inner) => &inner.meta,
52        }
53    }
54}
55impl<R>
56    From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::describe_accelerator_offerings::DescribeAcceleratorOfferingsError, R>>
57    for Error
58where
59    R: Send + Sync + std::fmt::Debug + 'static,
60{
61    fn from(
62        err: ::aws_smithy_runtime_api::client::result::SdkError<
63            crate::operation::describe_accelerator_offerings::DescribeAcceleratorOfferingsError,
64            R,
65        >,
66    ) -> Self {
67        match err {
68            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
69            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
70                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
71                source: err.into(),
72            }),
73        }
74    }
75}
76impl From<crate::operation::describe_accelerator_offerings::DescribeAcceleratorOfferingsError> for Error {
77    fn from(err: crate::operation::describe_accelerator_offerings::DescribeAcceleratorOfferingsError) -> Self {
78        match err {
79            crate::operation::describe_accelerator_offerings::DescribeAcceleratorOfferingsError::BadRequestException(inner) => {
80                Error::BadRequestException(inner)
81            }
82            crate::operation::describe_accelerator_offerings::DescribeAcceleratorOfferingsError::InternalServerException(inner) => {
83                Error::InternalServerException(inner)
84            }
85            crate::operation::describe_accelerator_offerings::DescribeAcceleratorOfferingsError::ResourceNotFoundException(inner) => {
86                Error::ResourceNotFoundException(inner)
87            }
88            crate::operation::describe_accelerator_offerings::DescribeAcceleratorOfferingsError::Unhandled(inner) => Error::Unhandled(inner),
89        }
90    }
91}
92impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::describe_accelerators::DescribeAcceleratorsError, R>> for Error
93where
94    R: Send + Sync + std::fmt::Debug + 'static,
95{
96    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::describe_accelerators::DescribeAcceleratorsError, R>) -> Self {
97        match err {
98            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
99            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
100                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
101                source: err.into(),
102            }),
103        }
104    }
105}
106impl From<crate::operation::describe_accelerators::DescribeAcceleratorsError> for Error {
107    fn from(err: crate::operation::describe_accelerators::DescribeAcceleratorsError) -> Self {
108        match err {
109            crate::operation::describe_accelerators::DescribeAcceleratorsError::BadRequestException(inner) => Error::BadRequestException(inner),
110            crate::operation::describe_accelerators::DescribeAcceleratorsError::InternalServerException(inner) => {
111                Error::InternalServerException(inner)
112            }
113            crate::operation::describe_accelerators::DescribeAcceleratorsError::ResourceNotFoundException(inner) => {
114                Error::ResourceNotFoundException(inner)
115            }
116            crate::operation::describe_accelerators::DescribeAcceleratorsError::Unhandled(inner) => Error::Unhandled(inner),
117        }
118    }
119}
120impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::describe_accelerator_types::DescribeAcceleratorTypesError, R>>
121    for Error
122where
123    R: Send + Sync + std::fmt::Debug + 'static,
124{
125    fn from(
126        err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::describe_accelerator_types::DescribeAcceleratorTypesError, R>,
127    ) -> Self {
128        match err {
129            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
130            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
131                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
132                source: err.into(),
133            }),
134        }
135    }
136}
137impl From<crate::operation::describe_accelerator_types::DescribeAcceleratorTypesError> for Error {
138    fn from(err: crate::operation::describe_accelerator_types::DescribeAcceleratorTypesError) -> Self {
139        match err {
140            crate::operation::describe_accelerator_types::DescribeAcceleratorTypesError::InternalServerException(inner) => {
141                Error::InternalServerException(inner)
142            }
143            crate::operation::describe_accelerator_types::DescribeAcceleratorTypesError::Unhandled(inner) => Error::Unhandled(inner),
144        }
145    }
146}
147impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::list_tags_for_resource::ListTagsForResourceError, R>> for Error
148where
149    R: Send + Sync + std::fmt::Debug + 'static,
150{
151    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::list_tags_for_resource::ListTagsForResourceError, R>) -> Self {
152        match err {
153            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
154            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
155                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
156                source: err.into(),
157            }),
158        }
159    }
160}
161impl From<crate::operation::list_tags_for_resource::ListTagsForResourceError> for Error {
162    fn from(err: crate::operation::list_tags_for_resource::ListTagsForResourceError) -> Self {
163        match err {
164            crate::operation::list_tags_for_resource::ListTagsForResourceError::BadRequestException(inner) => Error::BadRequestException(inner),
165            crate::operation::list_tags_for_resource::ListTagsForResourceError::InternalServerException(inner) => {
166                Error::InternalServerException(inner)
167            }
168            crate::operation::list_tags_for_resource::ListTagsForResourceError::ResourceNotFoundException(inner) => {
169                Error::ResourceNotFoundException(inner)
170            }
171            crate::operation::list_tags_for_resource::ListTagsForResourceError::Unhandled(inner) => Error::Unhandled(inner),
172        }
173    }
174}
175impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::tag_resource::TagResourceError, R>> for Error
176where
177    R: Send + Sync + std::fmt::Debug + 'static,
178{
179    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::tag_resource::TagResourceError, R>) -> Self {
180        match err {
181            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
182            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
183                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
184                source: err.into(),
185            }),
186        }
187    }
188}
189impl From<crate::operation::tag_resource::TagResourceError> for Error {
190    fn from(err: crate::operation::tag_resource::TagResourceError) -> Self {
191        match err {
192            crate::operation::tag_resource::TagResourceError::BadRequestException(inner) => Error::BadRequestException(inner),
193            crate::operation::tag_resource::TagResourceError::InternalServerException(inner) => Error::InternalServerException(inner),
194            crate::operation::tag_resource::TagResourceError::ResourceNotFoundException(inner) => Error::ResourceNotFoundException(inner),
195            crate::operation::tag_resource::TagResourceError::Unhandled(inner) => Error::Unhandled(inner),
196        }
197    }
198}
199impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::untag_resource::UntagResourceError, R>> for Error
200where
201    R: Send + Sync + std::fmt::Debug + 'static,
202{
203    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::untag_resource::UntagResourceError, R>) -> Self {
204        match err {
205            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
206            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
207                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
208                source: err.into(),
209            }),
210        }
211    }
212}
213impl From<crate::operation::untag_resource::UntagResourceError> for Error {
214    fn from(err: crate::operation::untag_resource::UntagResourceError) -> Self {
215        match err {
216            crate::operation::untag_resource::UntagResourceError::BadRequestException(inner) => Error::BadRequestException(inner),
217            crate::operation::untag_resource::UntagResourceError::InternalServerException(inner) => Error::InternalServerException(inner),
218            crate::operation::untag_resource::UntagResourceError::ResourceNotFoundException(inner) => Error::ResourceNotFoundException(inner),
219            crate::operation::untag_resource::UntagResourceError::Unhandled(inner) => Error::Unhandled(inner),
220        }
221    }
222}
223impl ::std::error::Error for Error {
224    fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
225        match self {
226            Error::BadRequestException(inner) => inner.source(),
227            Error::InternalServerException(inner) => inner.source(),
228            Error::ResourceNotFoundException(inner) => inner.source(),
229            Error::Unhandled(inner) => ::std::option::Option::Some(&*inner.source),
230        }
231    }
232}
233impl ::aws_types::request_id::RequestId for Error {
234    fn request_id(&self) -> Option<&str> {
235        match self {
236            Self::BadRequestException(e) => e.request_id(),
237            Self::InternalServerException(e) => e.request_id(),
238            Self::ResourceNotFoundException(e) => e.request_id(),
239            Self::Unhandled(e) => e.meta.request_id(),
240        }
241    }
242}