aws-sdk-sagemakergatewayruntime 1.0.0

AWS SDK for Amazon SageMaker Gateway Runtime
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
/// All possible error types for this service.
#[non_exhaustive]
#[derive(::std::fmt::Debug)]
pub enum Error {
    /// 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.
    AccessDeniedException(crate::types::error::AccessDeniedException),
    /// 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>
    /// ` -- 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:
    /// <status>
    /// <message>
    /// ` -- 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 (
    /// <component>
    /// ): `, 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.
    /// </component>
    /// </message>
    /// </status>
    /// </reason>
    BadGatewayException(crate::types::error::BadGatewayException),
    /// 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>
    /// <message>
    /// ` -- 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 (
    /// <component>
    /// ): `, 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.
    /// </component>
    /// </message>
    /// </status>
    GatewayTimeoutException(crate::types::error::GatewayTimeoutException),
    /// An unexpected internal failure occurred.
    InternalServerException(crate::types::error::InternalServerException),
    /// 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.
    InternalStreamFailure(crate::types::error::InternalStreamFailure),
    /// Reserved for a model error during the stream. Not currently sent; a failure after the stream starts is reported as InternalStreamFailure.
    ModelStreamError(crate::types::error::ModelStreamError),
    /// The request body exceeds the 10 MiB limit. Reduce the size of the payload and send the request again.
    PayloadTooLargeException(crate::types::error::PayloadTooLargeException),
    /// 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.
    ResourceNotFoundException(crate::types::error::ResourceNotFoundException),
    /// 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.
    ServiceUnavailableException(crate::types::error::ServiceUnavailableException),
    /// 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.
    ThrottlingException(crate::types::error::ThrottlingException),
    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
    variable wildcard pattern and check `.code()`:
     \
    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
     \
    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-Error) for what information is available for the error.")]
    Unhandled(crate::error::sealed_unhandled::Unhandled),
}
impl ::std::fmt::Display for Error {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Error::AccessDeniedException(inner) => inner.fmt(f),
            Error::BadGatewayException(inner) => inner.fmt(f),
            Error::GatewayTimeoutException(inner) => inner.fmt(f),
            Error::InternalServerException(inner) => inner.fmt(f),
            Error::InternalStreamFailure(inner) => inner.fmt(f),
            Error::ModelStreamError(inner) => inner.fmt(f),
            Error::PayloadTooLargeException(inner) => inner.fmt(f),
            Error::ResourceNotFoundException(inner) => inner.fmt(f),
            Error::ServiceUnavailableException(inner) => inner.fmt(f),
            Error::ThrottlingException(inner) => inner.fmt(f),
            Error::Unhandled(_) => {
                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
                    write!(f, "unhandled error ({code})")
                } else {
                    f.write_str("unhandled error")
                }
            }
        }
    }
}
impl From<::aws_smithy_types::error::operation::BuildError> for Error {
    fn from(value: ::aws_smithy_types::error::operation::BuildError) -> Self {
        Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
            source: value.into(),
            meta: ::std::default::Default::default(),
        })
    }
}
impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for Error {
    fn meta(&self) -> &::aws_smithy_types::error::metadata::ErrorMetadata {
        match self {
            Self::AccessDeniedException(inner) => inner.meta(),
            Self::BadGatewayException(inner) => inner.meta(),
            Self::GatewayTimeoutException(inner) => inner.meta(),
            Self::InternalServerException(inner) => inner.meta(),
            Self::InternalStreamFailure(inner) => inner.meta(),
            Self::ModelStreamError(inner) => inner.meta(),
            Self::PayloadTooLargeException(inner) => inner.meta(),
            Self::ResourceNotFoundException(inner) => inner.meta(),
            Self::ServiceUnavailableException(inner) => inner.meta(),
            Self::ThrottlingException(inner) => inner.meta(),
            Self::Unhandled(inner) => &inner.meta,
        }
    }
}
impl<R>
    From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError, R>>
    for Error
where
    R: Send + Sync + std::fmt::Debug + 'static,
{
    fn from(
        err: ::aws_smithy_runtime_api::client::result::SdkError<
            crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError,
            R,
        >,
    ) -> Self {
        match err {
            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
                source: err.into(),
            }),
        }
    }
}
impl From<crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError> for Error {
    fn from(err: crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError) -> Self {
        match err {
            crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError::AccessDeniedException(inner) => {
                Error::AccessDeniedException(inner)
            }
            crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError::BadGatewayException(inner) => {
                Error::BadGatewayException(inner)
            }
            crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError::GatewayTimeoutException(inner) => {
                Error::GatewayTimeoutException(inner)
            }
            crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError::InternalServerException(inner) => {
                Error::InternalServerException(inner)
            }
            crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError::PayloadTooLargeException(inner) => {
                Error::PayloadTooLargeException(inner)
            }
            crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError::ResourceNotFoundException(inner) => {
                Error::ResourceNotFoundException(inner)
            }
            crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError::ServiceUnavailableException(inner) => {
                Error::ServiceUnavailableException(inner)
            }
            crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError::ThrottlingException(inner) => {
                Error::ThrottlingException(inner)
            }
            crate::operation::invoke_global_inference_gateway::InvokeGlobalInferenceGatewayError::Unhandled(inner) => Error::Unhandled(inner),
        }
    }
}
impl<R>
    From<
        ::aws_smithy_runtime_api::client::result::SdkError<
            crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError,
            R,
        >,
    > for Error
where
    R: Send + Sync + std::fmt::Debug + 'static,
{
    fn from(
        err: ::aws_smithy_runtime_api::client::result::SdkError<
            crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError,
            R,
        >,
    ) -> Self {
        match err {
            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
                source: err.into(),
            }),
        }
    }
}
impl From<crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError> for Error {
    fn from(
        err: crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError,
    ) -> Self {
        match err {
            crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError::AccessDeniedException(inner) => Error::AccessDeniedException(inner),
            crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError::BadGatewayException(inner) => Error::BadGatewayException(inner),
            crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError::GatewayTimeoutException(inner) => Error::GatewayTimeoutException(inner),
            crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError::InternalServerException(inner) => Error::InternalServerException(inner),
            crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError::InternalStreamFailure(inner) => Error::InternalStreamFailure(inner),
            crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError::ModelStreamError(inner) => Error::ModelStreamError(inner),
            crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError::PayloadTooLargeException(inner) => Error::PayloadTooLargeException(inner),
            crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError::ResourceNotFoundException(inner) => Error::ResourceNotFoundException(inner),
            crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError::ServiceUnavailableException(inner) => Error::ServiceUnavailableException(inner),
            crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError::ThrottlingException(inner) => Error::ThrottlingException(inner),
            crate::operation::invoke_global_inference_gateway_with_response_stream::InvokeGlobalInferenceGatewayWithResponseStreamError::Unhandled(inner) => Error::Unhandled(inner),
        }
    }
}
impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::types::error::ResponseStreamError, R>> for Error
where
    R: Send + Sync + std::fmt::Debug + 'static,
{
    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::types::error::ResponseStreamError, R>) -> Self {
        match err {
            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
                source: err.into(),
            }),
        }
    }
}
impl From<crate::types::error::ResponseStreamError> for Error {
    fn from(err: crate::types::error::ResponseStreamError) -> Self {
        match err {
            crate::types::error::ResponseStreamError::ModelStreamError(inner) => Error::ModelStreamError(inner),
            crate::types::error::ResponseStreamError::InternalStreamFailure(inner) => Error::InternalStreamFailure(inner),
            crate::types::error::ResponseStreamError::Unhandled(inner) => Error::Unhandled(inner),
        }
    }
}
impl ::std::error::Error for Error {
    fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
        match self {
            Error::AccessDeniedException(inner) => inner.source(),
            Error::BadGatewayException(inner) => inner.source(),
            Error::GatewayTimeoutException(inner) => inner.source(),
            Error::InternalServerException(inner) => inner.source(),
            Error::InternalStreamFailure(inner) => inner.source(),
            Error::ModelStreamError(inner) => inner.source(),
            Error::PayloadTooLargeException(inner) => inner.source(),
            Error::ResourceNotFoundException(inner) => inner.source(),
            Error::ServiceUnavailableException(inner) => inner.source(),
            Error::ThrottlingException(inner) => inner.source(),
            Error::Unhandled(inner) => ::std::option::Option::Some(&*inner.source),
        }
    }
}
impl ::aws_types::request_id::RequestId for Error {
    fn request_id(&self) -> Option<&str> {
        match self {
            Self::AccessDeniedException(e) => e.request_id(),
            Self::BadGatewayException(e) => e.request_id(),
            Self::GatewayTimeoutException(e) => e.request_id(),
            Self::InternalServerException(e) => e.request_id(),
            Self::InternalStreamFailure(e) => e.request_id(),
            Self::ModelStreamError(e) => e.request_id(),
            Self::PayloadTooLargeException(e) => e.request_id(),
            Self::ResourceNotFoundException(e) => e.request_id(),
            Self::ServiceUnavailableException(e) => e.request_id(),
            Self::ThrottlingException(e) => e.request_id(),
            Self::Unhandled(e) => e.meta.request_id(),
        }
    }
}