aws_sdk_iottwinmaker/types/
_error_code.rs1#[allow(missing_docs)] #[non_exhaustive]
47#[derive(
48 ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::Ord, ::std::cmp::PartialEq, ::std::cmp::PartialOrd, ::std::fmt::Debug, ::std::hash::Hash,
49)]
50pub enum ErrorCode {
51 #[allow(missing_docs)] CompositeComponentFailure,
53 #[allow(missing_docs)] InternalFailure,
55 #[allow(missing_docs)] ProcessingError,
57 #[allow(missing_docs)] SyncCreatingError,
59 #[allow(missing_docs)] SyncDeletingError,
61 #[allow(missing_docs)] SyncInitializingError,
63 #[allow(missing_docs)] SyncProcessingError,
65 #[allow(missing_docs)] ValidationError,
67 #[deprecated(note = "Don't directly match on `Unknown`. See the docs on this enum for the correct way to handle unknown variants.")]
69 Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue),
70}
71impl ::std::convert::From<&str> for ErrorCode {
72 fn from(s: &str) -> Self {
73 match s {
74 "COMPOSITE_COMPONENT_FAILURE" => ErrorCode::CompositeComponentFailure,
75 "INTERNAL_FAILURE" => ErrorCode::InternalFailure,
76 "PROCESSING_ERROR" => ErrorCode::ProcessingError,
77 "SYNC_CREATING_ERROR" => ErrorCode::SyncCreatingError,
78 "SYNC_DELETING_ERROR" => ErrorCode::SyncDeletingError,
79 "SYNC_INITIALIZING_ERROR" => ErrorCode::SyncInitializingError,
80 "SYNC_PROCESSING_ERROR" => ErrorCode::SyncProcessingError,
81 "VALIDATION_ERROR" => ErrorCode::ValidationError,
82 other => ErrorCode::Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue(other.to_owned())),
83 }
84 }
85}
86impl ::std::str::FromStr for ErrorCode {
87 type Err = ::std::convert::Infallible;
88
89 fn from_str(s: &str) -> ::std::result::Result<Self, <Self as ::std::str::FromStr>::Err> {
90 ::std::result::Result::Ok(ErrorCode::from(s))
91 }
92}
93impl ErrorCode {
94 pub fn as_str(&self) -> &str {
96 match self {
97 ErrorCode::CompositeComponentFailure => "COMPOSITE_COMPONENT_FAILURE",
98 ErrorCode::InternalFailure => "INTERNAL_FAILURE",
99 ErrorCode::ProcessingError => "PROCESSING_ERROR",
100 ErrorCode::SyncCreatingError => "SYNC_CREATING_ERROR",
101 ErrorCode::SyncDeletingError => "SYNC_DELETING_ERROR",
102 ErrorCode::SyncInitializingError => "SYNC_INITIALIZING_ERROR",
103 ErrorCode::SyncProcessingError => "SYNC_PROCESSING_ERROR",
104 ErrorCode::ValidationError => "VALIDATION_ERROR",
105 ErrorCode::Unknown(value) => value.as_str(),
106 }
107 }
108 pub const fn values() -> &'static [&'static str] {
110 &[
111 "COMPOSITE_COMPONENT_FAILURE",
112 "INTERNAL_FAILURE",
113 "PROCESSING_ERROR",
114 "SYNC_CREATING_ERROR",
115 "SYNC_DELETING_ERROR",
116 "SYNC_INITIALIZING_ERROR",
117 "SYNC_PROCESSING_ERROR",
118 "VALIDATION_ERROR",
119 ]
120 }
121}
122impl ::std::convert::AsRef<str> for ErrorCode {
123 fn as_ref(&self) -> &str {
124 self.as_str()
125 }
126}
127impl ErrorCode {
128 pub fn try_parse(value: &str) -> ::std::result::Result<Self, crate::error::UnknownVariantError> {
132 match Self::from(value) {
133 #[allow(deprecated)]
134 Self::Unknown(_) => ::std::result::Result::Err(crate::error::UnknownVariantError::new(value)),
135 known => Ok(known),
136 }
137 }
138}
139impl ::std::fmt::Display for ErrorCode {
140 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
141 match self {
142 ErrorCode::CompositeComponentFailure => write!(f, "COMPOSITE_COMPONENT_FAILURE"),
143 ErrorCode::InternalFailure => write!(f, "INTERNAL_FAILURE"),
144 ErrorCode::ProcessingError => write!(f, "PROCESSING_ERROR"),
145 ErrorCode::SyncCreatingError => write!(f, "SYNC_CREATING_ERROR"),
146 ErrorCode::SyncDeletingError => write!(f, "SYNC_DELETING_ERROR"),
147 ErrorCode::SyncInitializingError => write!(f, "SYNC_INITIALIZING_ERROR"),
148 ErrorCode::SyncProcessingError => write!(f, "SYNC_PROCESSING_ERROR"),
149 ErrorCode::ValidationError => write!(f, "VALIDATION_ERROR"),
150 ErrorCode::Unknown(value) => write!(f, "{value}"),
151 }
152 }
153}