Skip to main content

aws_sdk_backupgateway/types/error/
_throttling_exception.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>TPS has been limited to protect against intentional or unintentional high request volumes.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct ThrottlingException {
7    /// <p>Error: TPS has been limited to protect against intentional or unintentional high request volumes.</p>
8    pub error_code: ::std::string::String,
9    #[allow(missing_docs)] // documentation missing in model
10    pub message: ::std::option::Option<::std::string::String>,
11    pub(crate) meta: ::aws_smithy_types::error::ErrorMetadata,
12}
13impl ThrottlingException {
14    /// <p>Error: TPS has been limited to protect against intentional or unintentional high request volumes.</p>
15    pub fn error_code(&self) -> &str {
16        use std::ops::Deref;
17        self.error_code.deref()
18    }
19}
20impl ThrottlingException {
21    /// Returns the error message.
22    pub fn message(&self) -> ::std::option::Option<&str> {
23        self.message.as_deref()
24    }
25}
26impl ::std::fmt::Display for ThrottlingException {
27    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
28        ::std::write!(f, "ThrottlingException")?;
29        if let ::std::option::Option::Some(inner_1) = &self.message {
30            {
31                ::std::write!(f, ": {inner_1}")?;
32            }
33        }
34        Ok(())
35    }
36}
37impl ::std::error::Error for ThrottlingException {}
38impl ::aws_types::request_id::RequestId for crate::types::error::ThrottlingException {
39    fn request_id(&self) -> Option<&str> {
40        use ::aws_smithy_types::error::metadata::ProvideErrorMetadata;
41        self.meta().request_id()
42    }
43}
44impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for ThrottlingException {
45    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
46        &self.meta
47    }
48}
49impl ThrottlingException {
50    /// Creates a new builder-style object to manufacture [`ThrottlingException`](crate::types::error::ThrottlingException).
51    pub fn builder() -> crate::types::error::builders::ThrottlingExceptionBuilder {
52        crate::types::error::builders::ThrottlingExceptionBuilder::default()
53    }
54}
55
56/// A builder for [`ThrottlingException`](crate::types::error::ThrottlingException).
57#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
58#[non_exhaustive]
59pub struct ThrottlingExceptionBuilder {
60    pub(crate) error_code: ::std::option::Option<::std::string::String>,
61    pub(crate) message: ::std::option::Option<::std::string::String>,
62    meta: std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
63}
64impl ThrottlingExceptionBuilder {
65    /// <p>Error: TPS has been limited to protect against intentional or unintentional high request volumes.</p>
66    /// This field is required.
67    pub fn error_code(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
68        self.error_code = ::std::option::Option::Some(input.into());
69        self
70    }
71    /// <p>Error: TPS has been limited to protect against intentional or unintentional high request volumes.</p>
72    pub fn set_error_code(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
73        self.error_code = input;
74        self
75    }
76    /// <p>Error: TPS has been limited to protect against intentional or unintentional high request volumes.</p>
77    pub fn get_error_code(&self) -> &::std::option::Option<::std::string::String> {
78        &self.error_code
79    }
80    #[allow(missing_docs)] // documentation missing in model
81    pub fn message(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
82        self.message = ::std::option::Option::Some(input.into());
83        self
84    }
85    #[allow(missing_docs)] // documentation missing in model
86    pub fn set_message(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
87        self.message = input;
88        self
89    }
90    #[allow(missing_docs)] // documentation missing in model
91    pub fn get_message(&self) -> &::std::option::Option<::std::string::String> {
92        &self.message
93    }
94    /// Sets error metadata
95    pub fn meta(mut self, meta: ::aws_smithy_types::error::ErrorMetadata) -> Self {
96        self.meta = Some(meta);
97        self
98    }
99
100    /// Sets error metadata
101    pub fn set_meta(&mut self, meta: std::option::Option<::aws_smithy_types::error::ErrorMetadata>) -> &mut Self {
102        self.meta = meta;
103        self
104    }
105    /// Consumes the builder and constructs a [`ThrottlingException`](crate::types::error::ThrottlingException).
106    /// This method will fail if any of the following fields are not set:
107    /// - [`error_code`](crate::types::error::builders::ThrottlingExceptionBuilder::error_code)
108    pub fn build(self) -> ::std::result::Result<crate::types::error::ThrottlingException, ::aws_smithy_types::error::operation::BuildError> {
109        ::std::result::Result::Ok(crate::types::error::ThrottlingException {
110            error_code: self.error_code.ok_or_else(|| {
111                ::aws_smithy_types::error::operation::BuildError::missing_field(
112                    "error_code",
113                    "error_code was not specified but it is required when building ThrottlingException",
114                )
115            })?,
116            message: self.message,
117            meta: self.meta.unwrap_or_default(),
118        })
119    }
120}