aws_sdk_personalizeruntime/
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>Provide a valid value for the field or parameter.</p>
7    InvalidInputException(crate::types::error::InvalidInputException),
8    /// <p>The specified resource 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::InvalidInputException(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::InvalidInputException(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::get_action_recommendations::GetActionRecommendationsError, R>>
52    for Error
53where
54    R: Send + Sync + std::fmt::Debug + 'static,
55{
56    fn from(
57        err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::get_action_recommendations::GetActionRecommendationsError, R>,
58    ) -> Self {
59        match err {
60            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
61            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
62                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
63                source: err.into(),
64            }),
65        }
66    }
67}
68impl From<crate::operation::get_action_recommendations::GetActionRecommendationsError> for Error {
69    fn from(err: crate::operation::get_action_recommendations::GetActionRecommendationsError) -> Self {
70        match err {
71            crate::operation::get_action_recommendations::GetActionRecommendationsError::InvalidInputException(inner) => {
72                Error::InvalidInputException(inner)
73            }
74            crate::operation::get_action_recommendations::GetActionRecommendationsError::ResourceNotFoundException(inner) => {
75                Error::ResourceNotFoundException(inner)
76            }
77            crate::operation::get_action_recommendations::GetActionRecommendationsError::Unhandled(inner) => Error::Unhandled(inner),
78        }
79    }
80}
81impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::get_personalized_ranking::GetPersonalizedRankingError, R>> for Error
82where
83    R: Send + Sync + std::fmt::Debug + 'static,
84{
85    fn from(
86        err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::get_personalized_ranking::GetPersonalizedRankingError, R>,
87    ) -> Self {
88        match err {
89            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
90            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
91                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
92                source: err.into(),
93            }),
94        }
95    }
96}
97impl From<crate::operation::get_personalized_ranking::GetPersonalizedRankingError> for Error {
98    fn from(err: crate::operation::get_personalized_ranking::GetPersonalizedRankingError) -> Self {
99        match err {
100            crate::operation::get_personalized_ranking::GetPersonalizedRankingError::InvalidInputException(inner) => {
101                Error::InvalidInputException(inner)
102            }
103            crate::operation::get_personalized_ranking::GetPersonalizedRankingError::ResourceNotFoundException(inner) => {
104                Error::ResourceNotFoundException(inner)
105            }
106            crate::operation::get_personalized_ranking::GetPersonalizedRankingError::Unhandled(inner) => Error::Unhandled(inner),
107        }
108    }
109}
110impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::get_recommendations::GetRecommendationsError, R>> for Error
111where
112    R: Send + Sync + std::fmt::Debug + 'static,
113{
114    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::get_recommendations::GetRecommendationsError, R>) -> Self {
115        match err {
116            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
117            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
118                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
119                source: err.into(),
120            }),
121        }
122    }
123}
124impl From<crate::operation::get_recommendations::GetRecommendationsError> for Error {
125    fn from(err: crate::operation::get_recommendations::GetRecommendationsError) -> Self {
126        match err {
127            crate::operation::get_recommendations::GetRecommendationsError::InvalidInputException(inner) => Error::InvalidInputException(inner),
128            crate::operation::get_recommendations::GetRecommendationsError::ResourceNotFoundException(inner) => {
129                Error::ResourceNotFoundException(inner)
130            }
131            crate::operation::get_recommendations::GetRecommendationsError::Unhandled(inner) => Error::Unhandled(inner),
132        }
133    }
134}
135impl ::std::error::Error for Error {
136    fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
137        match self {
138            Error::InvalidInputException(inner) => inner.source(),
139            Error::ResourceNotFoundException(inner) => inner.source(),
140            Error::Unhandled(inner) => ::std::option::Option::Some(&*inner.source),
141        }
142    }
143}
144impl ::aws_types::request_id::RequestId for Error {
145    fn request_id(&self) -> Option<&str> {
146        match self {
147            Self::InvalidInputException(e) => e.request_id(),
148            Self::ResourceNotFoundException(e) => e.request_id(),
149            Self::Unhandled(e) => e.meta.request_id(),
150        }
151    }
152}