aws_sdk_forecastquery/
error_meta.rs1#[non_exhaustive]
4#[derive(::std::fmt::Debug)]
5pub enum Error {
6 InvalidInputException(crate::types::error::InvalidInputException),
8 InvalidNextTokenException(crate::types::error::InvalidNextTokenException),
10 LimitExceededException(crate::types::error::LimitExceededException),
12 ResourceInUseException(crate::types::error::ResourceInUseException),
14 ResourceNotFoundException(crate::types::error::ResourceNotFoundException),
16 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
18 variable wildcard pattern and check `.code()`:
19 \
20 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
21 \
22 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-Error) for what information is available for the error.")]
23 Unhandled(crate::error::sealed_unhandled::Unhandled),
24}
25impl ::std::fmt::Display for Error {
26 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
27 match self {
28 Error::InvalidInputException(inner) => inner.fmt(f),
29 Error::InvalidNextTokenException(inner) => inner.fmt(f),
30 Error::LimitExceededException(inner) => inner.fmt(f),
31 Error::ResourceInUseException(inner) => inner.fmt(f),
32 Error::ResourceNotFoundException(inner) => inner.fmt(f),
33 Error::Unhandled(_) => {
34 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
35 write!(f, "unhandled error ({code})")
36 } else {
37 f.write_str("unhandled error")
38 }
39 }
40 }
41 }
42}
43impl From<::aws_smithy_types::error::operation::BuildError> for Error {
44 fn from(value: ::aws_smithy_types::error::operation::BuildError) -> Self {
45 Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
46 source: value.into(),
47 meta: ::std::default::Default::default(),
48 })
49 }
50}
51impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for Error {
52 fn meta(&self) -> &::aws_smithy_types::error::metadata::ErrorMetadata {
53 match self {
54 Self::InvalidInputException(inner) => inner.meta(),
55 Self::InvalidNextTokenException(inner) => inner.meta(),
56 Self::LimitExceededException(inner) => inner.meta(),
57 Self::ResourceInUseException(inner) => inner.meta(),
58 Self::ResourceNotFoundException(inner) => inner.meta(),
59 Self::Unhandled(inner) => &inner.meta,
60 }
61 }
62}
63impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::query_forecast::QueryForecastError, R>> for Error
64where
65 R: Send + Sync + std::fmt::Debug + 'static,
66{
67 fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::query_forecast::QueryForecastError, R>) -> Self {
68 match err {
69 ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
70 _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
71 meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
72 source: err.into(),
73 }),
74 }
75 }
76}
77impl From<crate::operation::query_forecast::QueryForecastError> for Error {
78 fn from(err: crate::operation::query_forecast::QueryForecastError) -> Self {
79 match err {
80 crate::operation::query_forecast::QueryForecastError::InvalidInputException(inner) => Error::InvalidInputException(inner),
81 crate::operation::query_forecast::QueryForecastError::InvalidNextTokenException(inner) => Error::InvalidNextTokenException(inner),
82 crate::operation::query_forecast::QueryForecastError::LimitExceededException(inner) => Error::LimitExceededException(inner),
83 crate::operation::query_forecast::QueryForecastError::ResourceInUseException(inner) => Error::ResourceInUseException(inner),
84 crate::operation::query_forecast::QueryForecastError::ResourceNotFoundException(inner) => Error::ResourceNotFoundException(inner),
85 crate::operation::query_forecast::QueryForecastError::Unhandled(inner) => Error::Unhandled(inner),
86 }
87 }
88}
89impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::query_what_if_forecast::QueryWhatIfForecastError, R>> for Error
90where
91 R: Send + Sync + std::fmt::Debug + 'static,
92{
93 fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::query_what_if_forecast::QueryWhatIfForecastError, R>) -> Self {
94 match err {
95 ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
96 _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
97 meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
98 source: err.into(),
99 }),
100 }
101 }
102}
103impl From<crate::operation::query_what_if_forecast::QueryWhatIfForecastError> for Error {
104 fn from(err: crate::operation::query_what_if_forecast::QueryWhatIfForecastError) -> Self {
105 match err {
106 crate::operation::query_what_if_forecast::QueryWhatIfForecastError::InvalidInputException(inner) => Error::InvalidInputException(inner),
107 crate::operation::query_what_if_forecast::QueryWhatIfForecastError::InvalidNextTokenException(inner) => {
108 Error::InvalidNextTokenException(inner)
109 }
110 crate::operation::query_what_if_forecast::QueryWhatIfForecastError::LimitExceededException(inner) => Error::LimitExceededException(inner),
111 crate::operation::query_what_if_forecast::QueryWhatIfForecastError::ResourceInUseException(inner) => Error::ResourceInUseException(inner),
112 crate::operation::query_what_if_forecast::QueryWhatIfForecastError::ResourceNotFoundException(inner) => {
113 Error::ResourceNotFoundException(inner)
114 }
115 crate::operation::query_what_if_forecast::QueryWhatIfForecastError::Unhandled(inner) => Error::Unhandled(inner),
116 }
117 }
118}
119impl ::std::error::Error for Error {
120 fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
121 match self {
122 Error::InvalidInputException(inner) => inner.source(),
123 Error::InvalidNextTokenException(inner) => inner.source(),
124 Error::LimitExceededException(inner) => inner.source(),
125 Error::ResourceInUseException(inner) => inner.source(),
126 Error::ResourceNotFoundException(inner) => inner.source(),
127 Error::Unhandled(inner) => ::std::option::Option::Some(&*inner.source),
128 }
129 }
130}
131impl ::aws_types::request_id::RequestId for Error {
132 fn request_id(&self) -> Option<&str> {
133 match self {
134 Self::InvalidInputException(e) => e.request_id(),
135 Self::InvalidNextTokenException(e) => e.request_id(),
136 Self::LimitExceededException(e) => e.request_id(),
137 Self::ResourceInUseException(e) => e.request_id(),
138 Self::ResourceNotFoundException(e) => e.request_id(),
139 Self::Unhandled(e) => e.meta.request_id(),
140 }
141 }
142}