aws_sdk_chimesdkmessaging/types/
_error_code.rs1#[allow(missing_docs)] #[non_exhaustive]
54#[derive(
55 ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::Ord, ::std::cmp::PartialEq, ::std::cmp::PartialOrd, ::std::fmt::Debug, ::std::hash::Hash,
56)]
57pub enum ErrorCode {
58 #[allow(missing_docs)] AccessDenied,
60 #[allow(missing_docs)] BadRequest,
62 #[allow(missing_docs)] Conflict,
64 #[allow(missing_docs)] Forbidden,
66 #[allow(missing_docs)] NotFound,
68 #[allow(missing_docs)] PhoneNumberAssociationsExist,
70 #[allow(missing_docs)] PreconditionFailed,
72 #[allow(missing_docs)] ResourceLimitExceeded,
74 #[allow(missing_docs)] ServiceFailure,
76 #[allow(missing_docs)] ServiceUnavailable,
78 #[allow(missing_docs)] Throttled,
80 #[allow(missing_docs)] Throttling,
82 #[allow(missing_docs)] Unauthorized,
84 #[allow(missing_docs)] Unprocessable,
86 #[allow(missing_docs)] VoiceConnectorGroupAssociationsExist,
88 #[deprecated(note = "Don't directly match on `Unknown`. See the docs on this enum for the correct way to handle unknown variants.")]
90 Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue),
91}
92impl ::std::convert::From<&str> for ErrorCode {
93 fn from(s: &str) -> Self {
94 match s {
95 "AccessDenied" => ErrorCode::AccessDenied,
96 "BadRequest" => ErrorCode::BadRequest,
97 "Conflict" => ErrorCode::Conflict,
98 "Forbidden" => ErrorCode::Forbidden,
99 "NotFound" => ErrorCode::NotFound,
100 "PhoneNumberAssociationsExist" => ErrorCode::PhoneNumberAssociationsExist,
101 "PreconditionFailed" => ErrorCode::PreconditionFailed,
102 "ResourceLimitExceeded" => ErrorCode::ResourceLimitExceeded,
103 "ServiceFailure" => ErrorCode::ServiceFailure,
104 "ServiceUnavailable" => ErrorCode::ServiceUnavailable,
105 "Throttled" => ErrorCode::Throttled,
106 "Throttling" => ErrorCode::Throttling,
107 "Unauthorized" => ErrorCode::Unauthorized,
108 "Unprocessable" => ErrorCode::Unprocessable,
109 "VoiceConnectorGroupAssociationsExist" => ErrorCode::VoiceConnectorGroupAssociationsExist,
110 other => ErrorCode::Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue(other.to_owned())),
111 }
112 }
113}
114impl ::std::str::FromStr for ErrorCode {
115 type Err = ::std::convert::Infallible;
116
117 fn from_str(s: &str) -> ::std::result::Result<Self, <Self as ::std::str::FromStr>::Err> {
118 ::std::result::Result::Ok(ErrorCode::from(s))
119 }
120}
121impl ErrorCode {
122 pub fn as_str(&self) -> &str {
124 match self {
125 ErrorCode::AccessDenied => "AccessDenied",
126 ErrorCode::BadRequest => "BadRequest",
127 ErrorCode::Conflict => "Conflict",
128 ErrorCode::Forbidden => "Forbidden",
129 ErrorCode::NotFound => "NotFound",
130 ErrorCode::PhoneNumberAssociationsExist => "PhoneNumberAssociationsExist",
131 ErrorCode::PreconditionFailed => "PreconditionFailed",
132 ErrorCode::ResourceLimitExceeded => "ResourceLimitExceeded",
133 ErrorCode::ServiceFailure => "ServiceFailure",
134 ErrorCode::ServiceUnavailable => "ServiceUnavailable",
135 ErrorCode::Throttled => "Throttled",
136 ErrorCode::Throttling => "Throttling",
137 ErrorCode::Unauthorized => "Unauthorized",
138 ErrorCode::Unprocessable => "Unprocessable",
139 ErrorCode::VoiceConnectorGroupAssociationsExist => "VoiceConnectorGroupAssociationsExist",
140 ErrorCode::Unknown(value) => value.as_str(),
141 }
142 }
143 pub const fn values() -> &'static [&'static str] {
145 &[
146 "AccessDenied",
147 "BadRequest",
148 "Conflict",
149 "Forbidden",
150 "NotFound",
151 "PhoneNumberAssociationsExist",
152 "PreconditionFailed",
153 "ResourceLimitExceeded",
154 "ServiceFailure",
155 "ServiceUnavailable",
156 "Throttled",
157 "Throttling",
158 "Unauthorized",
159 "Unprocessable",
160 "VoiceConnectorGroupAssociationsExist",
161 ]
162 }
163}
164impl ::std::convert::AsRef<str> for ErrorCode {
165 fn as_ref(&self) -> &str {
166 self.as_str()
167 }
168}
169impl ErrorCode {
170 pub fn try_parse(value: &str) -> ::std::result::Result<Self, crate::error::UnknownVariantError> {
174 match Self::from(value) {
175 #[allow(deprecated)]
176 Self::Unknown(_) => ::std::result::Result::Err(crate::error::UnknownVariantError::new(value)),
177 known => Ok(known),
178 }
179 }
180}
181impl ::std::fmt::Display for ErrorCode {
182 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
183 match self {
184 ErrorCode::AccessDenied => write!(f, "AccessDenied"),
185 ErrorCode::BadRequest => write!(f, "BadRequest"),
186 ErrorCode::Conflict => write!(f, "Conflict"),
187 ErrorCode::Forbidden => write!(f, "Forbidden"),
188 ErrorCode::NotFound => write!(f, "NotFound"),
189 ErrorCode::PhoneNumberAssociationsExist => write!(f, "PhoneNumberAssociationsExist"),
190 ErrorCode::PreconditionFailed => write!(f, "PreconditionFailed"),
191 ErrorCode::ResourceLimitExceeded => write!(f, "ResourceLimitExceeded"),
192 ErrorCode::ServiceFailure => write!(f, "ServiceFailure"),
193 ErrorCode::ServiceUnavailable => write!(f, "ServiceUnavailable"),
194 ErrorCode::Throttled => write!(f, "Throttled"),
195 ErrorCode::Throttling => write!(f, "Throttling"),
196 ErrorCode::Unauthorized => write!(f, "Unauthorized"),
197 ErrorCode::Unprocessable => write!(f, "Unprocessable"),
198 ErrorCode::VoiceConnectorGroupAssociationsExist => write!(f, "VoiceConnectorGroupAssociationsExist"),
199 ErrorCode::Unknown(value) => write!(f, "{value}"),
200 }
201 }
202}