aws-sdk-sagemakerruntime 1.100.0

AWS SDK for Amazon SageMaker Runtime
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub use crate::types::error::_internal_dependency_exception::InternalDependencyException;

pub use crate::types::error::_internal_failure::InternalFailure;

pub use crate::types::error::_model_error::ModelError;

pub use crate::types::error::_model_not_ready_exception::ModelNotReadyException;

pub use crate::types::error::_service_unavailable::ServiceUnavailable;

pub use crate::types::error::_validation_error::ValidationError;

pub use crate::types::error::_internal_stream_failure::InternalStreamFailure;

pub use crate::types::error::_model_stream_error::ModelStreamError;

/// Error type for the `ResponseStreamError` operation.
#[non_exhaustive]
#[derive(::std::fmt::Debug)]
pub enum ResponseStreamError {
    /// <p>An error occurred while streaming the response body. This error can have the following error codes:</p>
    /// <dl>
    /// <dt>
    /// ModelInvocationTimeExceeded
    /// </dt>
    /// <dd>
    /// <p>The model failed to finish sending the response within the timeout period allowed by Amazon SageMaker AI.</p>
    /// </dd>
    /// <dt>
    /// StreamBroken
    /// </dt>
    /// <dd>
    /// <p>The Transmission Control Protocol (TCP) connection between the client and the model was reset or closed.</p>
    /// </dd>
    /// </dl>
    ModelStreamError(crate::types::error::ModelStreamError),
    /// <p>The stream processing failed because of an unknown error, exception or failure. Try your request again.</p>
    InternalStreamFailure(crate::types::error::InternalStreamFailure),
    /// 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-ResponseStreamError) for what information is available for the error.")]
    Unhandled(crate::error::sealed_unhandled::Unhandled),
}
impl ResponseStreamError {
    /// Creates the `ResponseStreamError::Unhandled` variant from any error type.
    pub fn unhandled(
        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
    ) -> Self {
        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
            source: err.into(),
            meta: ::std::default::Default::default(),
        })
    }

    /// Creates the `ResponseStreamError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
            source: err.clone().into(),
            meta: err,
        })
    }
    ///
    /// Returns error metadata, which includes the error code, message,
    /// request ID, and potentially additional information.
    ///
    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
        match self {
            Self::ModelStreamError(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
            Self::InternalStreamFailure(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
            Self::Unhandled(e) => &e.meta,
        }
    }
    /// Returns `true` if the error kind is `ResponseStreamError::ModelStreamError`.
    pub fn is_model_stream_error(&self) -> bool {
        matches!(self, Self::ModelStreamError(_))
    }
    /// Returns `true` if the error kind is `ResponseStreamError::InternalStreamFailure`.
    pub fn is_internal_stream_failure(&self) -> bool {
        matches!(self, Self::InternalStreamFailure(_))
    }
}
impl ::std::error::Error for ResponseStreamError {
    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
        match self {
            Self::ModelStreamError(_inner) => ::std::option::Option::Some(_inner),
            Self::InternalStreamFailure(_inner) => ::std::option::Option::Some(_inner),
            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
        }
    }
}
impl ::std::fmt::Display for ResponseStreamError {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        match self {
            Self::ModelStreamError(_inner) => _inner.fmt(f),
            Self::InternalStreamFailure(_inner) => _inner.fmt(f),
            Self::Unhandled(_inner) => {
                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 ::aws_smithy_types::retry::ProvideErrorKind for ResponseStreamError {
    fn code(&self) -> ::std::option::Option<&str> {
        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
    }
    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
        ::std::option::Option::None
    }
}
impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for ResponseStreamError {
    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
        match self {
            Self::ModelStreamError(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
            Self::InternalStreamFailure(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
            Self::Unhandled(_inner) => &_inner.meta,
        }
    }
}
impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for ResponseStreamError {
    fn create_unhandled_error(
        source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
        meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
    ) -> Self {
        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
            source,
            meta: meta.unwrap_or_default(),
        })
    }
}
impl ::aws_types::request_id::RequestId for crate::types::error::ResponseStreamError {
    fn request_id(&self) -> Option<&str> {
        self.meta().request_id()
    }
}

mod _internal_dependency_exception;

mod _internal_failure;

mod _internal_stream_failure;

mod _model_error;

mod _model_not_ready_exception;

mod _model_stream_error;

mod _service_unavailable;

mod _validation_error;

/// Builders
pub mod builders;