Skip to main content

aws_sdk_dynamodb/types/error/
_conditional_check_failed_exception.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>A condition specified in the operation failed to be evaluated.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct ConditionalCheckFailedException {
7    /// <p>The conditional request failed.</p>
8    pub message: ::std::option::Option<::std::string::String>,
9    /// <p>Item which caused the <code>ConditionalCheckFailedException</code>.</p>
10    pub item: ::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>>,
11    pub(crate) meta: ::aws_smithy_types::error::ErrorMetadata,
12}
13impl ConditionalCheckFailedException {
14    /// <p>Item which caused the <code>ConditionalCheckFailedException</code>.</p>
15    pub fn item(&self) -> ::std::option::Option<&::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>> {
16        self.item.as_ref()
17    }
18}
19impl ConditionalCheckFailedException {
20    /// Returns the error message.
21    pub fn message(&self) -> ::std::option::Option<&str> {
22        self.message.as_deref()
23    }
24}
25impl ::std::fmt::Display for ConditionalCheckFailedException {
26    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
27        ::std::write!(f, "ConditionalCheckFailedException")?;
28        if let ::std::option::Option::Some(inner_1) = &self.message {
29            {
30                ::std::write!(f, ": {inner_1}")?;
31            }
32        }
33        Ok(())
34    }
35}
36impl ::std::error::Error for ConditionalCheckFailedException {}
37impl ::aws_types::request_id::RequestId for crate::types::error::ConditionalCheckFailedException {
38    fn request_id(&self) -> Option<&str> {
39        use ::aws_smithy_types::error::metadata::ProvideErrorMetadata;
40        self.meta().request_id()
41    }
42}
43impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for ConditionalCheckFailedException {
44    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
45        &self.meta
46    }
47}
48impl ConditionalCheckFailedException {
49    /// Creates a new builder-style object to manufacture [`ConditionalCheckFailedException`](crate::types::error::ConditionalCheckFailedException).
50    pub fn builder() -> crate::types::error::builders::ConditionalCheckFailedExceptionBuilder {
51        crate::types::error::builders::ConditionalCheckFailedExceptionBuilder::default()
52    }
53}
54
55/// A builder for [`ConditionalCheckFailedException`](crate::types::error::ConditionalCheckFailedException).
56#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
57#[non_exhaustive]
58pub struct ConditionalCheckFailedExceptionBuilder {
59    pub(crate) message: ::std::option::Option<::std::string::String>,
60    pub(crate) item: ::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>>,
61    meta: std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
62}
63impl ConditionalCheckFailedExceptionBuilder {
64    /// <p>The conditional request failed.</p>
65    pub fn message(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
66        self.message = ::std::option::Option::Some(input.into());
67        self
68    }
69    /// <p>The conditional request failed.</p>
70    pub fn set_message(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
71        self.message = input;
72        self
73    }
74    /// <p>The conditional request failed.</p>
75    pub fn get_message(&self) -> &::std::option::Option<::std::string::String> {
76        &self.message
77    }
78    /// Adds a key-value pair to `item`.
79    ///
80    /// To override the contents of this collection use [`set_item`](Self::set_item).
81    ///
82    /// <p>Item which caused the <code>ConditionalCheckFailedException</code>.</p>
83    pub fn item(mut self, k: impl ::std::convert::Into<::std::string::String>, v: crate::types::AttributeValue) -> Self {
84        let mut hash_map = self.item.unwrap_or_default();
85        hash_map.insert(k.into(), v);
86        self.item = ::std::option::Option::Some(hash_map);
87        self
88    }
89    /// <p>Item which caused the <code>ConditionalCheckFailedException</code>.</p>
90    pub fn set_item(
91        mut self,
92        input: ::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>>,
93    ) -> Self {
94        self.item = input;
95        self
96    }
97    /// <p>Item which caused the <code>ConditionalCheckFailedException</code>.</p>
98    pub fn get_item(&self) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>> {
99        &self.item
100    }
101    /// Sets error metadata
102    pub fn meta(mut self, meta: ::aws_smithy_types::error::ErrorMetadata) -> Self {
103        self.meta = Some(meta);
104        self
105    }
106
107    /// Sets error metadata
108    pub fn set_meta(&mut self, meta: std::option::Option<::aws_smithy_types::error::ErrorMetadata>) -> &mut Self {
109        self.meta = meta;
110        self
111    }
112    /// Consumes the builder and constructs a [`ConditionalCheckFailedException`](crate::types::error::ConditionalCheckFailedException).
113    pub fn build(self) -> crate::types::error::ConditionalCheckFailedException {
114        crate::types::error::ConditionalCheckFailedException {
115            message: self.message,
116            item: self.item,
117            meta: self.meta.unwrap_or_default(),
118        }
119    }
120}