aws_sdk_cloudsearchdomain/
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>Information about any problems encountered while processing an upload request.</p>
7    DocumentServiceException(crate::types::error::DocumentServiceException),
8    /// <p>Information about any problems encountered while processing a search request.</p>
9    SearchException(crate::types::error::SearchException),
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::DocumentServiceException(inner) => inner.fmt(f),
23            Error::SearchException(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::DocumentServiceException(inner) => inner.meta(),
46            Self::SearchException(inner) => inner.meta(),
47            Self::Unhandled(inner) => &inner.meta,
48        }
49    }
50}
51impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::search::SearchError, 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::search::SearchError, 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::search::SearchError> for Error {
66    fn from(err: crate::operation::search::SearchError) -> Self {
67        match err {
68            crate::operation::search::SearchError::SearchException(inner) => Error::SearchException(inner),
69            crate::operation::search::SearchError::Unhandled(inner) => Error::Unhandled(inner),
70        }
71    }
72}
73impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::suggest::SuggestError, 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::suggest::SuggestError, 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::suggest::SuggestError> for Error {
88    fn from(err: crate::operation::suggest::SuggestError) -> Self {
89        match err {
90            crate::operation::suggest::SuggestError::SearchException(inner) => Error::SearchException(inner),
91            crate::operation::suggest::SuggestError::Unhandled(inner) => Error::Unhandled(inner),
92        }
93    }
94}
95impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::upload_documents::UploadDocumentsError, 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::upload_documents::UploadDocumentsError, 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::upload_documents::UploadDocumentsError> for Error {
110    fn from(err: crate::operation::upload_documents::UploadDocumentsError) -> Self {
111        match err {
112            crate::operation::upload_documents::UploadDocumentsError::DocumentServiceException(inner) => Error::DocumentServiceException(inner),
113            crate::operation::upload_documents::UploadDocumentsError::Unhandled(inner) => Error::Unhandled(inner),
114        }
115    }
116}
117impl ::std::error::Error for Error {
118    fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
119        match self {
120            Error::DocumentServiceException(inner) => inner.source(),
121            Error::SearchException(inner) => inner.source(),
122            Error::Unhandled(inner) => ::std::option::Option::Some(&*inner.source),
123        }
124    }
125}
126impl ::aws_types::request_id::RequestId for Error {
127    fn request_id(&self) -> Option<&str> {
128        match self {
129            Self::DocumentServiceException(e) => e.request_id(),
130            Self::SearchException(e) => e.request_id(),
131            Self::Unhandled(e) => e.meta.request_id(),
132        }
133    }
134}