Skip to main content

aws_sdk_agentdiscovery/
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    /// Thrown on an internal defect — a bug or malformed state, not a failed dependency.
7    /// <p>⚠️ Deliberately a **permanent** failure. Repeating a request that failed to serialize will fail identically, so treating a 500 as retryable would spin a poison message through redelivery forever instead of letting it reach a dead-letter queue. Dependency failures that *are* worth retrying use `ServiceUnavailableException` and its 503 instead.</p>
8    InternalServerException(crate::types::error::InternalServerException),
9    /// Thrown when the caller exceeds a rate/burst limit (D-9). ARD's code for it is `RATE_LIMIT_EXCEEDED`.
10    ThrottlingException(crate::types::error::ThrottlingException),
11    /// Thrown when a request fails input validation.
12    /// <p>`errorCode` carries ARD's Appendix B code, `INVALID_ARGUMENT`, which ARD's OpenAPI makes a required member of every error body on the ARD surface. The Amazon-shaped and internal surfaces leave it unset.</p>
13    ValidationException(crate::types::error::ValidationException),
14    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
15    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
16    variable wildcard pattern and check `.code()`:
17     \
18    &nbsp;&nbsp;&nbsp;`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::InternalServerException(inner) => inner.fmt(f),
27            Error::ThrottlingException(inner) => inner.fmt(f),
28            Error::ValidationException(inner) => inner.fmt(f),
29            Error::Unhandled(_) => {
30                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
31                    write!(f, "unhandled error ({code})")
32                } else {
33                    f.write_str("unhandled error")
34                }
35            }
36        }
37    }
38}
39impl From<::aws_smithy_types::error::operation::BuildError> for Error {
40    fn from(value: ::aws_smithy_types::error::operation::BuildError) -> Self {
41        Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
42            source: value.into(),
43            meta: ::std::default::Default::default(),
44        })
45    }
46}
47impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for Error {
48    fn meta(&self) -> &::aws_smithy_types::error::metadata::ErrorMetadata {
49        match self {
50            Self::InternalServerException(inner) => inner.meta(),
51            Self::ThrottlingException(inner) => inner.meta(),
52            Self::ValidationException(inner) => inner.meta(),
53            Self::Unhandled(inner) => &inner.meta,
54        }
55    }
56}
57impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::search_public_records::SearchPublicRecordsError, R>> for Error
58where
59    R: Send + Sync + std::fmt::Debug + 'static,
60{
61    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::search_public_records::SearchPublicRecordsError, R>) -> Self {
62        match err {
63            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
64            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
65                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
66                source: err.into(),
67            }),
68        }
69    }
70}
71impl From<crate::operation::search_public_records::SearchPublicRecordsError> for Error {
72    fn from(err: crate::operation::search_public_records::SearchPublicRecordsError) -> Self {
73        match err {
74            crate::operation::search_public_records::SearchPublicRecordsError::InternalServerException(inner) => {
75                Error::InternalServerException(inner)
76            }
77            crate::operation::search_public_records::SearchPublicRecordsError::ThrottlingException(inner) => Error::ThrottlingException(inner),
78            crate::operation::search_public_records::SearchPublicRecordsError::ValidationException(inner) => Error::ValidationException(inner),
79            crate::operation::search_public_records::SearchPublicRecordsError::Unhandled(inner) => Error::Unhandled(inner),
80        }
81    }
82}
83impl ::std::error::Error for Error {
84    fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
85        match self {
86            Error::InternalServerException(inner) => inner.source(),
87            Error::ThrottlingException(inner) => inner.source(),
88            Error::ValidationException(inner) => inner.source(),
89            Error::Unhandled(inner) => ::std::option::Option::Some(&*inner.source),
90        }
91    }
92}
93impl ::aws_types::request_id::RequestId for Error {
94    fn request_id(&self) -> Option<&str> {
95        match self {
96            Self::InternalServerException(e) => e.request_id(),
97            Self::ThrottlingException(e) => e.request_id(),
98            Self::ValidationException(e) => e.request_id(),
99            Self::Unhandled(e) => e.meta.request_id(),
100        }
101    }
102}