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