aws_sdk_sagemakerruntimehttp2/
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>The input fails to satisfy the constraints specified by an AWS service.</p>
7    InputValidationError(crate::types::error::InputValidationError),
8    /// <p>The request processing has failed because of an unknown error, exception or failure.</p>
9    InternalServerError(crate::types::error::InternalServerError),
10    /// <p>Internal stream failure that occurs during streaming.</p>
11    InternalStreamFailure(crate::types::error::InternalStreamFailure),
12    /// <p>An error occurred while processing the model.</p>
13    ModelError(crate::types::error::ModelError),
14    /// <p>Model stream error that occurs during streaming.</p>
15    ModelStreamError(crate::types::error::ModelStreamError),
16    /// <p>The request has failed due to a temporary failure of the server.</p>
17    ServiceUnavailableError(crate::types::error::ServiceUnavailableError),
18    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
19    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
20    variable wildcard pattern and check `.code()`:
21     \
22    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
23     \
24    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-Error) for what information is available for the error.")]
25    Unhandled(crate::error::sealed_unhandled::Unhandled),
26}
27impl ::std::fmt::Display for Error {
28    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29        match self {
30            Error::InputValidationError(inner) => inner.fmt(f),
31            Error::InternalServerError(inner) => inner.fmt(f),
32            Error::InternalStreamFailure(inner) => inner.fmt(f),
33            Error::ModelError(inner) => inner.fmt(f),
34            Error::ModelStreamError(inner) => inner.fmt(f),
35            Error::ServiceUnavailableError(inner) => inner.fmt(f),
36            Error::Unhandled(_) => {
37                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
38                    write!(f, "unhandled error ({code})")
39                } else {
40                    f.write_str("unhandled error")
41                }
42            }
43        }
44    }
45}
46impl From<::aws_smithy_types::error::operation::BuildError> for Error {
47    fn from(value: ::aws_smithy_types::error::operation::BuildError) -> Self {
48        Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
49            source: value.into(),
50            meta: ::std::default::Default::default(),
51        })
52    }
53}
54impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for Error {
55    fn meta(&self) -> &::aws_smithy_types::error::metadata::ErrorMetadata {
56        match self {
57            Self::InputValidationError(inner) => inner.meta(),
58            Self::InternalServerError(inner) => inner.meta(),
59            Self::InternalStreamFailure(inner) => inner.meta(),
60            Self::ModelError(inner) => inner.meta(),
61            Self::ModelStreamError(inner) => inner.meta(),
62            Self::ServiceUnavailableError(inner) => inner.meta(),
63            Self::Unhandled(inner) => &inner.meta,
64        }
65    }
66}
67impl<R>
68    From<
69        ::aws_smithy_runtime_api::client::result::SdkError<
70            crate::operation::invoke_endpoint_with_bidirectional_stream::InvokeEndpointWithBidirectionalStreamError,
71            R,
72        >,
73    > for Error
74where
75    R: Send + Sync + std::fmt::Debug + 'static,
76{
77    fn from(
78        err: ::aws_smithy_runtime_api::client::result::SdkError<
79            crate::operation::invoke_endpoint_with_bidirectional_stream::InvokeEndpointWithBidirectionalStreamError,
80            R,
81        >,
82    ) -> Self {
83        match err {
84            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
85            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
86                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
87                source: err.into(),
88            }),
89        }
90    }
91}
92impl From<crate::operation::invoke_endpoint_with_bidirectional_stream::InvokeEndpointWithBidirectionalStreamError> for Error {
93    fn from(err: crate::operation::invoke_endpoint_with_bidirectional_stream::InvokeEndpointWithBidirectionalStreamError) -> Self {
94        match err {
95            crate::operation::invoke_endpoint_with_bidirectional_stream::InvokeEndpointWithBidirectionalStreamError::InputValidationError(inner) => {
96                Error::InputValidationError(inner)
97            }
98            crate::operation::invoke_endpoint_with_bidirectional_stream::InvokeEndpointWithBidirectionalStreamError::InternalServerError(inner) => {
99                Error::InternalServerError(inner)
100            }
101            crate::operation::invoke_endpoint_with_bidirectional_stream::InvokeEndpointWithBidirectionalStreamError::InternalStreamFailure(inner) => {
102                Error::InternalStreamFailure(inner)
103            }
104            crate::operation::invoke_endpoint_with_bidirectional_stream::InvokeEndpointWithBidirectionalStreamError::ModelError(inner) => {
105                Error::ModelError(inner)
106            }
107            crate::operation::invoke_endpoint_with_bidirectional_stream::InvokeEndpointWithBidirectionalStreamError::ModelStreamError(inner) => {
108                Error::ModelStreamError(inner)
109            }
110            crate::operation::invoke_endpoint_with_bidirectional_stream::InvokeEndpointWithBidirectionalStreamError::ServiceUnavailableError(
111                inner,
112            ) => Error::ServiceUnavailableError(inner),
113            crate::operation::invoke_endpoint_with_bidirectional_stream::InvokeEndpointWithBidirectionalStreamError::Unhandled(inner) => {
114                Error::Unhandled(inner)
115            }
116        }
117    }
118}
119impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::types::error::RequestStreamEventError, R>> for Error
120where
121    R: Send + Sync + std::fmt::Debug + 'static,
122{
123    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::types::error::RequestStreamEventError, R>) -> Self {
124        match err {
125            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
126            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
127                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
128                source: err.into(),
129            }),
130        }
131    }
132}
133impl From<crate::types::error::RequestStreamEventError> for Error {
134    fn from(err: crate::types::error::RequestStreamEventError) -> Self {
135        match err {
136            crate::types::error::RequestStreamEventError::Unhandled(inner) => Error::Unhandled(inner),
137        }
138    }
139}
140impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::types::error::ResponseStreamEventError, R>> for Error
141where
142    R: Send + Sync + std::fmt::Debug + 'static,
143{
144    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::types::error::ResponseStreamEventError, R>) -> Self {
145        match err {
146            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
147            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
148                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
149                source: err.into(),
150            }),
151        }
152    }
153}
154impl From<crate::types::error::ResponseStreamEventError> for Error {
155    fn from(err: crate::types::error::ResponseStreamEventError) -> Self {
156        match err {
157            crate::types::error::ResponseStreamEventError::ModelStreamError(inner) => Error::ModelStreamError(inner),
158            crate::types::error::ResponseStreamEventError::InternalStreamFailure(inner) => Error::InternalStreamFailure(inner),
159            crate::types::error::ResponseStreamEventError::Unhandled(inner) => Error::Unhandled(inner),
160        }
161    }
162}
163impl ::std::error::Error for Error {
164    fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
165        match self {
166            Error::InputValidationError(inner) => inner.source(),
167            Error::InternalServerError(inner) => inner.source(),
168            Error::InternalStreamFailure(inner) => inner.source(),
169            Error::ModelError(inner) => inner.source(),
170            Error::ModelStreamError(inner) => inner.source(),
171            Error::ServiceUnavailableError(inner) => inner.source(),
172            Error::Unhandled(inner) => ::std::option::Option::Some(&*inner.source),
173        }
174    }
175}
176impl ::aws_types::request_id::RequestId for Error {
177    fn request_id(&self) -> Option<&str> {
178        match self {
179            Self::InputValidationError(e) => e.request_id(),
180            Self::InternalServerError(e) => e.request_id(),
181            Self::InternalStreamFailure(e) => e.request_id(),
182            Self::ModelError(e) => e.request_id(),
183            Self::ModelStreamError(e) => e.request_id(),
184            Self::ServiceUnavailableError(e) => e.request_id(),
185            Self::Unhandled(e) => e.meta.request_id(),
186        }
187    }
188}