aws_sdk_qldbsession/
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    /// <p>Returned if the request is malformed or contains an error such as an invalid parameter value or a missing required parameter.</p>
7    BadRequestException(crate::types::error::BadRequestException),
8    /// <p>Returned when the request exceeds the processing capacity of the ledger.</p>
9    CapacityExceededException(crate::types::error::CapacityExceededException),
10    /// <p>Returned if the session doesn't exist anymore because it timed out or expired.</p>
11    InvalidSessionException(crate::types::error::InvalidSessionException),
12    /// <p>Returned if a resource limit such as number of active sessions is exceeded.</p>
13    LimitExceededException(crate::types::error::LimitExceededException),
14    /// <p>Returned when a transaction cannot be written to the journal due to a failure in the verification phase of <i>optimistic concurrency control</i> (OCC).</p>
15    OccConflictException(crate::types::error::OccConflictException),
16    /// <p>Returned when the rate of requests exceeds the allowed throughput.</p>
17    RateExceededException(crate::types::error::RateExceededException),
18    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
19    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
20    variable wildcard pattern and check `.code()`:
21     \
22    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
23     \
24    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-Error) for what information is available for the error.")]
25    Unhandled(crate::error::sealed_unhandled::Unhandled),
26}
27impl ::std::fmt::Display for Error {
28    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29        match self {
30            Error::BadRequestException(inner) => inner.fmt(f),
31            Error::CapacityExceededException(inner) => inner.fmt(f),
32            Error::InvalidSessionException(inner) => inner.fmt(f),
33            Error::LimitExceededException(inner) => inner.fmt(f),
34            Error::OccConflictException(inner) => inner.fmt(f),
35            Error::RateExceededException(inner) => inner.fmt(f),
36            Error::Unhandled(_) => {
37                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
38                    write!(f, "unhandled error ({code})")
39                } else {
40                    f.write_str("unhandled error")
41                }
42            }
43        }
44    }
45}
46impl From<::aws_smithy_types::error::operation::BuildError> for Error {
47    fn from(value: ::aws_smithy_types::error::operation::BuildError) -> Self {
48        Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
49            source: value.into(),
50            meta: ::std::default::Default::default(),
51        })
52    }
53}
54impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for Error {
55    fn meta(&self) -> &::aws_smithy_types::error::metadata::ErrorMetadata {
56        match self {
57            Self::BadRequestException(inner) => inner.meta(),
58            Self::CapacityExceededException(inner) => inner.meta(),
59            Self::InvalidSessionException(inner) => inner.meta(),
60            Self::LimitExceededException(inner) => inner.meta(),
61            Self::OccConflictException(inner) => inner.meta(),
62            Self::RateExceededException(inner) => inner.meta(),
63            Self::Unhandled(inner) => &inner.meta,
64        }
65    }
66}
67impl<R> From<::aws_smithy_runtime_api::client::result::SdkError<crate::operation::send_command::SendCommandError, R>> for Error
68where
69    R: Send + Sync + std::fmt::Debug + 'static,
70{
71    fn from(err: ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::send_command::SendCommandError, R>) -> Self {
72        match err {
73            ::aws_smithy_runtime_api::client::result::SdkError::ServiceError(context) => Self::from(context.into_err()),
74            _ => Error::Unhandled(crate::error::sealed_unhandled::Unhandled {
75                meta: ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(&err).clone(),
76                source: err.into(),
77            }),
78        }
79    }
80}
81impl From<crate::operation::send_command::SendCommandError> for Error {
82    fn from(err: crate::operation::send_command::SendCommandError) -> Self {
83        match err {
84            crate::operation::send_command::SendCommandError::BadRequestException(inner) => Error::BadRequestException(inner),
85            crate::operation::send_command::SendCommandError::CapacityExceededException(inner) => Error::CapacityExceededException(inner),
86            crate::operation::send_command::SendCommandError::InvalidSessionException(inner) => Error::InvalidSessionException(inner),
87            crate::operation::send_command::SendCommandError::LimitExceededException(inner) => Error::LimitExceededException(inner),
88            crate::operation::send_command::SendCommandError::OccConflictException(inner) => Error::OccConflictException(inner),
89            crate::operation::send_command::SendCommandError::RateExceededException(inner) => Error::RateExceededException(inner),
90            crate::operation::send_command::SendCommandError::Unhandled(inner) => Error::Unhandled(inner),
91        }
92    }
93}
94impl ::std::error::Error for Error {
95    fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
96        match self {
97            Error::BadRequestException(inner) => inner.source(),
98            Error::CapacityExceededException(inner) => inner.source(),
99            Error::InvalidSessionException(inner) => inner.source(),
100            Error::LimitExceededException(inner) => inner.source(),
101            Error::OccConflictException(inner) => inner.source(),
102            Error::RateExceededException(inner) => inner.source(),
103            Error::Unhandled(inner) => ::std::option::Option::Some(&*inner.source),
104        }
105    }
106}
107impl ::aws_types::request_id::RequestId for Error {
108    fn request_id(&self) -> Option<&str> {
109        match self {
110            Self::BadRequestException(e) => e.request_id(),
111            Self::CapacityExceededException(e) => e.request_id(),
112            Self::InvalidSessionException(e) => e.request_id(),
113            Self::LimitExceededException(e) => e.request_id(),
114            Self::OccConflictException(e) => e.request_id(),
115            Self::RateExceededException(e) => e.request_id(),
116            Self::Unhandled(e) => e.meta.request_id(),
117        }
118    }
119}