aws_sdk_sagemakerruntime/
error_meta.rs1#[non_exhaustive]
4#[derive(::std::fmt::Debug)]
5pub enum Error {
6 InternalDependencyException(crate::types::error::InternalDependencyException),
8 InternalFailure(crate::types::error::InternalFailure),
10 InternalStreamFailure(crate::types::error::InternalStreamFailure),
12 ModelError(crate::types::error::ModelError),
14 ModelNotReadyException(crate::types::error::ModelNotReadyException),
16 ModelStreamError(crate::types::error::ModelStreamError),
32 ServiceUnavailable(crate::types::error::ServiceUnavailable),
34 ValidationError(crate::types::error::ValidationError),
36 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
38 variable wildcard pattern and check `.code()`:
39 \
40 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
41 \
42 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-Error) for what information is available for the error.")]
43 Unhandled(crate::error::sealed_unhandled::Unhandled),
44}
45impl ::std::fmt::Display for Error {
46 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
47 match self {
48 Error::InternalDependencyException(inner) => inner.fmt(f),
49 Error::InternalFailure(inner) => inner.fmt(f),
50 Error::InternalStreamFailure(inner) => inner.fmt(f),
51 Error::ModelError(inner) => inner.fmt(f),
52 Error::ModelNotReadyException(inner) => inner.fmt(f),
53 Error::ModelStreamError(inner) => inner.fmt(f),
54 Error::ServiceUnavailable(inner) => inner.fmt(f),
55 Error::ValidationError(inner) => inner.fmt(f),
56 Error::Unhandled(_) => {
57 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
58 write!(f, "unhandled error ({code})")
59 } else {
60 f.write_str("unhandled error")
61 }
62 }
63 }
64 }
65}
66impl From<::aws_smithy_types::error::operation::BuildError> for Error {
67 fn from(value: ::aws_smithy_types::error::operation::BuildError) -> Self {
68 Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
69 source: value.into(),
70 meta: ::std::default::Default::default(),
71 })
72 }
73}
74impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for Error {
75 fn meta(&self) -> &::aws_smithy_types::error::metadata::ErrorMetadata {
76 match self {
77 Self::InternalDependencyException(inner) => inner.meta(),
78 Self::InternalFailure(inner) => inner.meta(),
79 Self::InternalStreamFailure(inner) => inner.meta(),
80 Self::ModelError(inner) => inner.meta(),
81 Self::ModelNotReadyException(inner) => inner.meta(),
82 Self::ModelStreamError(inner) => inner.meta(),
83 Self::ServiceUnavailable(inner) => inner.meta(),
84 Self::ValidationError(inner) => inner.meta(),
85 Self::Unhandled(inner) => &inner.meta,
86 }
87 }
88}
89impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::invoke_endpoint::InvokeEndpointError, 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::invoke_endpoint::InvokeEndpointError, 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::invoke_endpoint::InvokeEndpointError> for Error {
104 fn from(err: crate::operation::invoke_endpoint::InvokeEndpointError) -> Self {
105 match err {
106 crate::operation::invoke_endpoint::InvokeEndpointError::InternalDependencyException(inner) => Error::InternalDependencyException(inner),
107 crate::operation::invoke_endpoint::InvokeEndpointError::InternalFailure(inner) => Error::InternalFailure(inner),
108 crate::operation::invoke_endpoint::InvokeEndpointError::ModelError(inner) => Error::ModelError(inner),
109 crate::operation::invoke_endpoint::InvokeEndpointError::ModelNotReadyException(inner) => Error::ModelNotReadyException(inner),
110 crate::operation::invoke_endpoint::InvokeEndpointError::ServiceUnavailable(inner) => Error::ServiceUnavailable(inner),
111 crate::operation::invoke_endpoint::InvokeEndpointError::ValidationError(inner) => Error::ValidationError(inner),
112 crate::operation::invoke_endpoint::InvokeEndpointError::Unhandled(inner) => Error::Unhandled(inner),
113 }
114 }
115}
116impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::invoke_endpoint_async::InvokeEndpointAsyncError, R>> for Error
117where
118 R: Send + Sync + std::fmt::Debug + 'static,
119{
120 fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::invoke_endpoint_async::InvokeEndpointAsyncError, R>) -> Self {
121 match err {
122 ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
123 _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
124 meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
125 source: err.into(),
126 }),
127 }
128 }
129}
130impl From<crate::operation::invoke_endpoint_async::InvokeEndpointAsyncError> for Error {
131 fn from(err: crate::operation::invoke_endpoint_async::InvokeEndpointAsyncError) -> Self {
132 match err {
133 crate::operation::invoke_endpoint_async::InvokeEndpointAsyncError::InternalFailure(inner) => Error::InternalFailure(inner),
134 crate::operation::invoke_endpoint_async::InvokeEndpointAsyncError::ServiceUnavailable(inner) => Error::ServiceUnavailable(inner),
135 crate::operation::invoke_endpoint_async::InvokeEndpointAsyncError::ValidationError(inner) => Error::ValidationError(inner),
136 crate::operation::invoke_endpoint_async::InvokeEndpointAsyncError::Unhandled(inner) => Error::Unhandled(inner),
137 }
138 }
139}
140impl<R>
141 From<
142 ::aws_smithy_runtime_api::client::result::SdkError<
143 crate::operation::invoke_endpoint_with_response_stream::InvokeEndpointWithResponseStreamError,
144 R,
145 >,
146 > for Error
147where
148 R: Send + Sync + std::fmt::Debug + 'static,
149{
150 fn from(
151 err: ::aws_smithy_runtime_api::client::result::SdkError<
152 crate::operation::invoke_endpoint_with_response_stream::InvokeEndpointWithResponseStreamError,
153 R,
154 >,
155 ) -> Self {
156 match err {
157 ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
158 _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
159 meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
160 source: err.into(),
161 }),
162 }
163 }
164}
165impl From<crate::operation::invoke_endpoint_with_response_stream::InvokeEndpointWithResponseStreamError> for Error {
166 fn from(err: crate::operation::invoke_endpoint_with_response_stream::InvokeEndpointWithResponseStreamError) -> Self {
167 match err {
168 crate::operation::invoke_endpoint_with_response_stream::InvokeEndpointWithResponseStreamError::InternalFailure(inner) => {
169 Error::InternalFailure(inner)
170 }
171 crate::operation::invoke_endpoint_with_response_stream::InvokeEndpointWithResponseStreamError::ValidationError(inner) => {
172 Error::ValidationError(inner)
173 }
174 crate::operation::invoke_endpoint_with_response_stream::InvokeEndpointWithResponseStreamError::ModelError(inner) => {
175 Error::ModelError(inner)
176 }
177 crate::operation::invoke_endpoint_with_response_stream::InvokeEndpointWithResponseStreamError::ModelStreamError(inner) => {
178 Error::ModelStreamError(inner)
179 }
180 crate::operation::invoke_endpoint_with_response_stream::InvokeEndpointWithResponseStreamError::InternalStreamFailure(inner) => {
181 Error::InternalStreamFailure(inner)
182 }
183 crate::operation::invoke_endpoint_with_response_stream::InvokeEndpointWithResponseStreamError::ServiceUnavailable(inner) => {
184 Error::ServiceUnavailable(inner)
185 }
186 crate::operation::invoke_endpoint_with_response_stream::InvokeEndpointWithResponseStreamError::Unhandled(inner) => {
187 Error::Unhandled(inner)
188 }
189 }
190 }
191}
192impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::types::error::ResponseStreamError, R>> for Error
193where
194 R: Send + Sync + std::fmt::Debug + 'static,
195{
196 fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::types::error::ResponseStreamError, R>) -> Self {
197 match err {
198 ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
199 _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
200 meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
201 source: err.into(),
202 }),
203 }
204 }
205}
206impl From<crate::types::error::ResponseStreamError> for Error {
207 fn from(err: crate::types::error::ResponseStreamError) -> Self {
208 match err {
209 crate::types::error::ResponseStreamError::ModelStreamError(inner) => Error::ModelStreamError(inner),
210 crate::types::error::ResponseStreamError::InternalStreamFailure(inner) => Error::InternalStreamFailure(inner),
211 crate::types::error::ResponseStreamError::Unhandled(inner) => Error::Unhandled(inner),
212 }
213 }
214}
215impl ::std::error::Error for Error {
216 fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
217 match self {
218 Error::InternalDependencyException(inner) => inner.source(),
219 Error::InternalFailure(inner) => inner.source(),
220 Error::InternalStreamFailure(inner) => inner.source(),
221 Error::ModelError(inner) => inner.source(),
222 Error::ModelNotReadyException(inner) => inner.source(),
223 Error::ModelStreamError(inner) => inner.source(),
224 Error::ServiceUnavailable(inner) => inner.source(),
225 Error::ValidationError(inner) => inner.source(),
226 Error::Unhandled(inner) => ::std::option::Option::Some(&*inner.source),
227 }
228 }
229}
230impl ::aws_types::request_id::RequestId for Error {
231 fn request_id(&self) -> Option<&str> {
232 match self {
233 Self::InternalDependencyException(e) => e.request_id(),
234 Self::InternalFailure(e) => e.request_id(),
235 Self::InternalStreamFailure(e) => e.request_id(),
236 Self::ModelError(e) => e.request_id(),
237 Self::ModelNotReadyException(e) => e.request_id(),
238 Self::ModelStreamError(e) => e.request_id(),
239 Self::ServiceUnavailable(e) => e.request_id(),
240 Self::ValidationError(e) => e.request_id(),
241 Self::Unhandled(e) => e.meta.request_id(),
242 }
243 }
244}