aws_sdk_sagemakerruntime/
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>Your request caused an exception with an internal dependency. Contact customer support.</p>
7    InternalDependencyException(crate::types::error::InternalDependencyException),
8    /// <p>An internal failure occurred.</p>
9    InternalFailure(crate::types::error::InternalFailure),
10    /// <p>The stream processing failed because of an unknown error, exception or failure. Try your request again.</p>
11    InternalStreamFailure(crate::types::error::InternalStreamFailure),
12    /// <p>Model (owned by the customer in the container) returned 4xx or 5xx error code.</p>
13    ModelError(crate::types::error::ModelError),
14    /// <p>Either a serverless endpoint variant's resources are still being provisioned, or a multi-model endpoint is still downloading or loading the target model. Wait and try your request again.</p>
15    ModelNotReadyException(crate::types::error::ModelNotReadyException),
16    /// <p>An error occurred while streaming the response body. This error can have the following error codes:</p>
17    /// <dl>
18    /// <dt>
19    /// ModelInvocationTimeExceeded
20    /// </dt>
21    /// <dd>
22    /// <p>The model failed to finish sending the response within the timeout period allowed by Amazon SageMaker AI.</p>
23    /// </dd>
24    /// <dt>
25    /// StreamBroken
26    /// </dt>
27    /// <dd>
28    /// <p>The Transmission Control Protocol (TCP) connection between the client and the model was reset or closed.</p>
29    /// </dd>
30    /// </dl>
31    ModelStreamError(crate::types::error::ModelStreamError),
32    /// <p>The service is unavailable. Try your call again.</p>
33    ServiceUnavailable(crate::types::error::ServiceUnavailable),
34    /// <p>Inspect your request and try again.</p>
35    ValidationError(crate::types::error::ValidationError),
36    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
37    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
38    variable wildcard pattern and check `.code()`:
39     \
40    &nbsp;&nbsp;&nbsp;`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}