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