Skip to main content

aws_sdk_sagemakergatewayruntime/
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    /// The caller is not authorized to invoke this gateway. Invoking requires the `sagemaker:InvokeGlobalInferenceGateway` permission, or `sagemaker:InvokeGlobalInferenceGatewayWithResponseStream` for the streaming operation, on the gateway ARN. A message starting `inference gateway` means the inference gateway serving the model refused the request with a 401 or 403, for example for its customer identity token. Its status code is in the message (the response status is 403), and up to 256 bytes of its error message are quoted.
7    AccessDeniedException(crate::types::error::AccessDeniedException),
8    /// 502 -- The gateway could not get a usable response from the inference gateway. The `Message` prefix says why: * `Global Inference Gateway: could not reach the inference gateway: <reason>
9    /// ` -- the request could not be sent, or the connection closed before a response arrived (for example, the connection failed, or the inference gateway closed it after reading the request). * `Global Inference Gateway: timed out waiting for the inference gateway` -- on the buffered operation, the inference gateway stopped sending partway through the response body and the gateway's read timeout expired. (The same text on a GatewayTimeoutException means no response arrived.) * Any other `Global Inference Gateway: ` message -- the gateway ended a response before it was complete, for example because it exceeded the 10 MiB limit of the buffered operation, the request exceeded its maximum duration, or the inference gateway was taken out of service. * `inference gateway:
10    /// <status>
11    /// <message>
12    /// ` -- the inference gateway serving the model returned a 502, 500, 503 or another 5xx error. Its status code is in the message (the response status is 502), and up to 256 bytes of its error message are quoted. * `inference gateway: response ended unexpectedly` -- the inference gateway's connection failed while it was sending the response. The inference gateway names a component in the prefix when it reports one: `inference gateway (
13    /// <component>
14    /// ): `, where the component is `config` (the inference gateway's configuration and proxy layer), `scheduler` (its request scheduler), `model selector` (its model selector) or `model server` (the model server). Not modeled as retryable: a 502 can mean the inference already ran, and the gateway may already have tried another inference gateway. Standard SDK retry modes may still retry a 5xx status, which would run (and bill) the inference again; set max attempts to 1 if a repeated inference is unacceptable.
15    /// </component>
16    /// </message>
17    /// </status>
18    /// </reason>
19    BadGatewayException(crate::types::error::BadGatewayException),
20    /// 504 -- The inference gateway did not respond in time. The `Message` prefix says whose time limit expired: * `Global Inference Gateway: timed out waiting for the inference gateway` -- the gateway's limit on the wait for the first part of the response. * `inference gateway: <status>
21    /// <message>
22    /// ` -- the inference gateway serving the model returned a 504, or a 408 because it timed out waiting for the request to arrive. Its status code is in the message (the response status is 504), and up to 256 bytes of its error message are quoted. The inference gateway names a component in the prefix when it reports one: `inference gateway (
23    /// <component>
24    /// ): `, where the component is `config` (the inference gateway's configuration and proxy layer), `scheduler` (its request scheduler), `model selector` (its model selector) or `model server` (the model server). Not modeled as retryable: a timeout does not prove the inference did not run, and the gateway may already have tried another inference gateway. Standard SDK retry modes may still retry a 5xx status, which could run (and bill) the inference again; set max attempts to 1 if a repeated inference is unacceptable.
25    /// </component>
26    /// </message>
27    /// </status>
28    GatewayTimeoutException(crate::types::error::GatewayTimeoutException),
29    /// An unexpected internal failure occurred.
30    InternalServerException(crate::types::error::InternalServerException),
31    /// A failure after the stream started. The `Message` says where it came from: `Global Inference Gateway: ` when a gateway time limit expired or the inference gateway was taken out of service, or `inference gateway: response ended unexpectedly` when the inference gateway's connection failed while it was sending the response. The stream ends after this event.
32    InternalStreamFailure(crate::types::error::InternalStreamFailure),
33    /// Reserved for a model error during the stream. Not currently sent; a failure after the stream starts is reported as InternalStreamFailure.
34    ModelStreamError(crate::types::error::ModelStreamError),
35    /// The request body exceeds the 10 MiB limit. Reduce the size of the payload and send the request again.
36    PayloadTooLargeException(crate::types::error::PayloadTooLargeException),
37    /// No gateway with this ID exists in this account and Region, or no target of the gateway serves the model named in the request body. A model that is served but has no available target right now returns ServiceUnavailableException instead. A message starting `inference gateway` means the inference gateway serving the model returned a 404; up to 256 bytes of its error message are quoted.
38    ResourceNotFoundException(crate::types::error::ResourceNotFoundException),
39    /// The service is temporarily unable to serve the request, for example because no capacity is available for the requested model. The request was not dispatched for inference. A 503 returned by the inference gateway serving the model after dispatch is reported as BadGatewayException, with the 503 in its `Message`, not as this error.
40    ServiceUnavailableException(crate::types::error::ServiceUnavailableException),
41    /// The request was throttled before it was dispatched for inference. Retry the request with backoff, after the `Retry-After` seconds when the response carries one. A message starting `inference gateway` means the last inference gateway tried for the model returned a 429. The gateway may have tried others first, and they may have failed for other reasons. Up to 256 bytes of its error message are quoted.
42    ThrottlingException(crate::types::error::ThrottlingException),
43    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
44    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
45    variable wildcard pattern and check `.code()`:
46     \
47    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
48     \
49    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-Error) for what information is available for the error.")]
50    Unhandled(crate::error::sealed_unhandled::Unhandled),
51}
52impl ::std::fmt::Display for Error {
53    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
54        match self {
55            Error::AccessDeniedException(inner) => inner.fmt(f),
56            Error::BadGatewayException(inner) => inner.fmt(f),
57            Error::GatewayTimeoutException(inner) => inner.fmt(f),
58            Error::InternalServerException(inner) => inner.fmt(f),
59            Error::InternalStreamFailure(inner) => inner.fmt(f),
60            Error::ModelStreamError(inner) => inner.fmt(f),
61            Error::PayloadTooLargeException(inner) => inner.fmt(f),
62            Error::ResourceNotFoundException(inner) => inner.fmt(f),
63            Error::ServiceUnavailableException(inner) => inner.fmt(f),
64            Error::ThrottlingException(inner) => inner.fmt(f),
65            Error::Unhandled(_) => {
66                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
67                    write!(f, "unhandled error ({code})")
68                } else {
69                    f.write_str("unhandled error")
70                }
71            }
72        }
73    }
74}
75impl From<::aws_smithy_types::error::operation::BuildError> for Error {
76    fn from(value: ::aws_smithy_types::error::operation::BuildError) -> Self {
77        Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
78            source: value.into(),
79            meta: ::std::default::Default::default(),
80        })
81    }
82}
83impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for Error {
84    fn meta(&self) -> &::aws_smithy_types::error::metadata::ErrorMetadata {
85        match self {
86            Self::AccessDeniedException(inner) => inner.meta(),
87            Self::BadGatewayException(inner) => inner.meta(),
88            Self::GatewayTimeoutException(inner) => inner.meta(),
89            Self::InternalServerException(inner) => inner.meta(),
90            Self::InternalStreamFailure(inner) => inner.meta(),
91            Self::ModelStreamError(inner) => inner.meta(),
92            Self::PayloadTooLargeException(inner) => inner.meta(),
93            Self::ResourceNotFoundException(inner) => inner.meta(),
94            Self::ServiceUnavailableException(inner) => inner.meta(),
95            Self::ThrottlingException(inner) => inner.meta(),
96            Self::Unhandled(inner) => &inner.meta,
97        }
98    }
99}
100impl<R>
101    From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError, R>>
102    for Error
103where
104    R: Send + Sync + std::fmt::Debug + 'static,
105{
106    fn from(
107        err: ::aws_smithy_runtime_api::client::result::SdkError<
108            crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError,
109            R,
110        >,
111    ) -> Self {
112        match err {
113            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
114            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
115                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
116                source: err.into(),
117            }),
118        }
119    }
120}
121impl From<crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError> for Error {
122    fn from(err: crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError) -> Self {
123        match err {
124            crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError::AccessDeniedException(inner) => {
125                Error::AccessDeniedException(inner)
126            }
127            crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError::BadGatewayException(inner) => {
128                Error::BadGatewayException(inner)
129            }
130            crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError::GatewayTimeoutException(inner) => {
131                Error::GatewayTimeoutException(inner)
132            }
133            crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError::InternalServerException(inner) => {
134                Error::InternalServerException(inner)
135            }
136            crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError::PayloadTooLargeException(inner) => {
137                Error::PayloadTooLargeException(inner)
138            }
139            crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError::ResourceNotFoundException(inner) => {
140                Error::ResourceNotFoundException(inner)
141            }
142            crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError::ServiceUnavailableException(inner) => {
143                Error::ServiceUnavailableException(inner)
144            }
145            crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError::ThrottlingException(inner) => {
146                Error::ThrottlingException(inner)
147            }
148            crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError::Unhandled(inner) => Error::Unhandled(inner),
149        }
150    }
151}
152impl<R>
153    From<
154        ::aws_smithy_runtime_api::client::result::SdkError<
155            crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError,
156            R,
157        >,
158    > for Error
159where
160    R: Send + Sync + std::fmt::Debug + 'static,
161{
162    fn from(
163        err: ::aws_smithy_runtime_api::client::result::SdkError<
164            crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError,
165            R,
166        >,
167    ) -> Self {
168        match err {
169            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
170            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
171                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
172                source: err.into(),
173            }),
174        }
175    }
176}
177impl From<crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError> for Error {
178    fn from(
179        err: crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError,
180    ) -> Self {
181        match err {
182            crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError::AccessDeniedException(inner) => Error::AccessDeniedException(inner),
183            crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError::BadGatewayException(inner) => Error::BadGatewayException(inner),
184            crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError::GatewayTimeoutException(inner) => Error::GatewayTimeoutException(inner),
185            crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError::InternalServerException(inner) => Error::InternalServerException(inner),
186            crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError::InternalStreamFailure(inner) => Error::InternalStreamFailure(inner),
187            crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError::ModelStreamError(inner) => Error::ModelStreamError(inner),
188            crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError::PayloadTooLargeException(inner) => Error::PayloadTooLargeException(inner),
189            crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError::ResourceNotFoundException(inner) => Error::ResourceNotFoundException(inner),
190            crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError::ServiceUnavailableException(inner) => Error::ServiceUnavailableException(inner),
191            crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError::ThrottlingException(inner) => Error::ThrottlingException(inner),
192            crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError::Unhandled(inner) => Error::Unhandled(inner),
193        }
194    }
195}
196impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::types::error::ResponseStreamError, R>> for Error
197where
198    R: Send + Sync + std::fmt::Debug + 'static,
199{
200    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::types::error::ResponseStreamError, R>) -> Self {
201        match err {
202            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
203            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
204                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
205                source: err.into(),
206            }),
207        }
208    }
209}
210impl From<crate::types::error::ResponseStreamError> for Error {
211    fn from(err: crate::types::error::ResponseStreamError) -> Self {
212        match err {
213            crate::types::error::ResponseStreamError::ModelStreamError(inner) => Error::ModelStreamError(inner),
214            crate::types::error::ResponseStreamError::InternalStreamFailure(inner) => Error::InternalStreamFailure(inner),
215            crate::types::error::ResponseStreamError::Unhandled(inner) => Error::Unhandled(inner),
216        }
217    }
218}
219impl ::std::error::Error for Error {
220    fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
221        match self {
222            Error::AccessDeniedException(inner) => inner.source(),
223            Error::BadGatewayException(inner) => inner.source(),
224            Error::GatewayTimeoutException(inner) => inner.source(),
225            Error::InternalServerException(inner) => inner.source(),
226            Error::InternalStreamFailure(inner) => inner.source(),
227            Error::ModelStreamError(inner) => inner.source(),
228            Error::PayloadTooLargeException(inner) => inner.source(),
229            Error::ResourceNotFoundException(inner) => inner.source(),
230            Error::ServiceUnavailableException(inner) => inner.source(),
231            Error::ThrottlingException(inner) => inner.source(),
232            Error::Unhandled(inner) => ::std::option::Option::Some(&*inner.source),
233        }
234    }
235}
236impl ::aws_types::request_id::RequestId for Error {
237    fn request_id(&self) -> Option<&str> {
238        match self {
239            Self::AccessDeniedException(e) => e.request_id(),
240            Self::BadGatewayException(e) => e.request_id(),
241            Self::GatewayTimeoutException(e) => e.request_id(),
242            Self::InternalServerException(e) => e.request_id(),
243            Self::InternalStreamFailure(e) => e.request_id(),
244            Self::ModelStreamError(e) => e.request_id(),
245            Self::PayloadTooLargeException(e) => e.request_id(),
246            Self::ResourceNotFoundException(e) => e.request_id(),
247            Self::ServiceUnavailableException(e) => e.request_id(),
248            Self::ThrottlingException(e) => e.request_id(),
249            Self::Unhandled(e) => e.meta.request_id(),
250        }
251    }
252}