Skip to main content

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