aws_sdk_sagemakermetrics/
error_meta.rs1#[non_exhaustive]
4#[derive(::std::fmt::Debug)]
5pub enum Error {
6 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
8 variable wildcard pattern and check `.code()`:
9 \
10 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
11 \
12 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-Error) for what information is available for the error.")]
13 Unhandled(crate::error::sealed_unhandled::Unhandled),
14}
15impl ::std::fmt::Display for Error {
16 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
17 match self {
18 Error::Unhandled(_) => {
19 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
20 write!(f, "unhandled error ({code})")
21 } else {
22 f.write_str("unhandled error")
23 }
24 }
25 }
26 }
27}
28impl From<::aws_smithy_types::error::operation::BuildError> for Error {
29 fn from(value: ::aws_smithy_types::error::operation::BuildError) -> Self {
30 Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
31 source: value.into(),
32 meta: ::std::default::Default::default(),
33 })
34 }
35}
36impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for Error {
37 fn meta(&self) -> &::aws_smithy_types::error::metadata::ErrorMetadata {
38 match self {
39 Self::Unhandled(inner) => &inner.meta,
40 }
41 }
42}
43impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::batch_get_metrics::BatchGetMetricsError, R>> for Error
44where
45 R: Send + Sync + std::fmt::Debug + 'static,
46{
47 fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::batch_get_metrics::BatchGetMetricsError, R>) -> Self {
48 match err {
49 ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
50 _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
51 meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
52 source: err.into(),
53 }),
54 }
55 }
56}
57impl From<crate::operation::batch_get_metrics::BatchGetMetricsError> for Error {
58 fn from(err: crate::operation::batch_get_metrics::BatchGetMetricsError) -> Self {
59 match err {
60 crate::operation::batch_get_metrics::BatchGetMetricsError::Unhandled(inner) => Error::Unhandled(inner),
61 }
62 }
63}
64impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::batch_put_metrics::BatchPutMetricsError, R>> for Error
65where
66 R: Send + Sync + std::fmt::Debug + 'static,
67{
68 fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::batch_put_metrics::BatchPutMetricsError, R>) -> Self {
69 match err {
70 ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
71 _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
72 meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
73 source: err.into(),
74 }),
75 }
76 }
77}
78impl From<crate::operation::batch_put_metrics::BatchPutMetricsError> for Error {
79 fn from(err: crate::operation::batch_put_metrics::BatchPutMetricsError) -> Self {
80 match err {
81 crate::operation::batch_put_metrics::BatchPutMetricsError::Unhandled(inner) => Error::Unhandled(inner),
82 }
83 }
84}
85impl ::std::error::Error for Error {
86 fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
87 match self {
88 Error::Unhandled(inner) => ::std::option::Option::Some(&*inner.source),
89 }
90 }
91}
92impl ::aws_types::request_id::RequestId for Error {
93 fn request_id(&self) -> Option<&str> {
94 match self {
95 Self::Unhandled(e) => e.meta.request_id(),
96 }
97 }
98}