aws-sdk-sagemakerruntimehttp2 1.7.0

AWS SDK for Amazon SageMaker Runtime HTTP2
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 {
    /// <p>The input fails to satisfy the constraints specified by an AWS service.</p>
    InputValidationError(crate::types::error::InputValidationError),
    /// <p>The request processing has failed because of an unknown error, exception or failure.</p>
    InternalServerError(crate::types::error::InternalServerError),
    /// <p>Internal stream failure that occurs during streaming.</p>
    InternalStreamFailure(crate::types::error::InternalStreamFailure),
    /// <p>An error occurred while processing the model.</p>
    ModelError(crate::types::error::ModelError),
    /// <p>Model stream error that occurs during streaming.</p>
    ModelStreamError(crate::types::error::ModelStreamError),
    /// <p>The request has failed due to a temporary failure of the server.</p>
    ServiceUnavailableError(crate::types::error::ServiceUnavailableError),
    /// 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::InputValidationError(inner) => inner.fmt(f),
            Error::InternalServerError(inner) => inner.fmt(f),
            Error::InternalStreamFailure(inner) => inner.fmt(f),
            Error::ModelError(inner) => inner.fmt(f),
            Error::ModelStreamError(inner) => inner.fmt(f),
            Error::ServiceUnavailableError(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::InputValidationError(inner) => inner.meta(),
            Self::InternalServerError(inner) => inner.meta(),
            Self::InternalStreamFailure(inner) => inner.meta(),
            Self::ModelError(inner) => inner.meta(),
            Self::ModelStreamError(inner) => inner.meta(),
            Self::ServiceUnavailableError(inner) => inner.meta(),
            Self::Unhandled(inner) => &inner.meta,
        }
    }
}
impl<R>
    From<
        ::aws_smithy_runtime_api::client::result::SdkError<
            crate::operation::invoke_endpoint_with_bidirectional_stream::InvokeEndpointWithBidirectionalStreamError,
            R,
        >,
    > for Error
where
    R: Send + Sync + std::fmt::Debug + 'static,
{
    fn from(
        err: ::aws_smithy_runtime_api::client::result::SdkError<
            crate::operation::invoke_endpoint_with_bidirectional_stream::InvokeEndpointWithBidirectionalStreamError,
            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_endpoint_with_bidirectional_stream::InvokeEndpointWithBidirectionalStreamError> for Error {
    fn from(err: crate::operation::invoke_endpoint_with_bidirectional_stream::InvokeEndpointWithBidirectionalStreamError) -> Self {
        match err {
            crate::operation::invoke_endpoint_with_bidirectional_stream::InvokeEndpointWithBidirectionalStreamError::InputValidationError(inner) => {
                Error::InputValidationError(inner)
            }
            crate::operation::invoke_endpoint_with_bidirectional_stream::InvokeEndpointWithBidirectionalStreamError::InternalServerError(inner) => {
                Error::InternalServerError(inner)
            }
            crate::operation::invoke_endpoint_with_bidirectional_stream::InvokeEndpointWithBidirectionalStreamError::InternalStreamFailure(inner) => {
                Error::InternalStreamFailure(inner)
            }
            crate::operation::invoke_endpoint_with_bidirectional_stream::InvokeEndpointWithBidirectionalStreamError::ModelError(inner) => {
                Error::ModelError(inner)
            }
            crate::operation::invoke_endpoint_with_bidirectional_stream::InvokeEndpointWithBidirectionalStreamError::ModelStreamError(inner) => {
                Error::ModelStreamError(inner)
            }
            crate::operation::invoke_endpoint_with_bidirectional_stream::InvokeEndpointWithBidirectionalStreamError::ServiceUnavailableError(
                inner,
            ) => Error::ServiceUnavailableError(inner),
            crate::operation::invoke_endpoint_with_bidirectional_stream::InvokeEndpointWithBidirectionalStreamError::Unhandled(inner) => {
                Error::Unhandled(inner)
            }
        }
    }
}
impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::types::error::RequestStreamEventError, R>> for Error
where
    R: Send + Sync + std::fmt::Debug + 'static,
{
    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::types::error::RequestStreamEventError, 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::RequestStreamEventError> for Error {
    fn from(err: crate::types::error::RequestStreamEventError) -> Self {
        match err {
            crate::types::error::RequestStreamEventError::Unhandled(inner) => Error::Unhandled(inner),
        }
    }
}
impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::types::error::ResponseStreamEventError, R>> for Error
where
    R: Send + Sync + std::fmt::Debug + 'static,
{
    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::types::error::ResponseStreamEventError, 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::ResponseStreamEventError> for Error {
    fn from(err: crate::types::error::ResponseStreamEventError) -> Self {
        match err {
            crate::types::error::ResponseStreamEventError::ModelStreamError(inner) => Error::ModelStreamError(inner),
            crate::types::error::ResponseStreamEventError::InternalStreamFailure(inner) => Error::InternalStreamFailure(inner),
            crate::types::error::ResponseStreamEventError::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::InputValidationError(inner) => inner.source(),
            Error::InternalServerError(inner) => inner.source(),
            Error::InternalStreamFailure(inner) => inner.source(),
            Error::ModelError(inner) => inner.source(),
            Error::ModelStreamError(inner) => inner.source(),
            Error::ServiceUnavailableError(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::InputValidationError(e) => e.request_id(),
            Self::InternalServerError(e) => e.request_id(),
            Self::InternalStreamFailure(e) => e.request_id(),
            Self::ModelError(e) => e.request_id(),
            Self::ModelStreamError(e) => e.request_id(),
            Self::ServiceUnavailableError(e) => e.request_id(),
            Self::Unhandled(e) => e.meta.request_id(),
        }
    }
}