aws_sdk_grafana/types/error/
_validation_exception.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>The value of a parameter in the request caused an error.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct ValidationException {
7    /// <p>A description of the error.</p>
8    pub message: ::std::string::String,
9    /// <p>The reason that the operation failed.</p>
10    pub reason: crate::types::ValidationExceptionReason,
11    /// <p>A list of fields that might be associated with the error.</p>
12    pub field_list: ::std::option::Option<::std::vec::Vec<crate::types::ValidationExceptionField>>,
13    pub(crate) meta: ::aws_smithy_types::error::ErrorMetadata,
14}
15impl ValidationException {
16    /// <p>The reason that the operation failed.</p>
17    pub fn reason(&self) -> &crate::types::ValidationExceptionReason {
18        &self.reason
19    }
20    /// <p>A list of fields that might be associated with the error.</p>
21    ///
22    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.field_list.is_none()`.
23    pub fn field_list(&self) -> &[crate::types::ValidationExceptionField] {
24        self.field_list.as_deref().unwrap_or_default()
25    }
26}
27impl ValidationException {
28    /// Returns the error message.
29    pub fn message(&self) -> &str {
30        &self.message
31    }
32}
33impl ::std::fmt::Display for ValidationException {
34    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
35        ::std::write!(f, "ValidationException")?;
36        {
37            ::std::write!(f, ": {}", &self.message)?;
38        }
39        Ok(())
40    }
41}
42impl ::std::error::Error for ValidationException {}
43impl ::aws_types::request_id::RequestId for crate::types::error::ValidationException {
44    fn request_id(&self) -> Option<&str> {
45        use ::aws_smithy_types::error::metadata::ProvideErrorMetadata;
46        self.meta().request_id()
47    }
48}
49impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for ValidationException {
50    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
51        &self.meta
52    }
53}
54impl ValidationException {
55    /// Creates a new builder-style object to manufacture [`ValidationException`](crate::types::error::ValidationException).
56    pub fn builder() -> crate::types::error::builders::ValidationExceptionBuilder {
57        crate::types::error::builders::ValidationExceptionBuilder::default()
58    }
59}
60
61/// A builder for [`ValidationException`](crate::types::error::ValidationException).
62#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
63#[non_exhaustive]
64pub struct ValidationExceptionBuilder {
65    pub(crate) message: ::std::option::Option<::std::string::String>,
66    pub(crate) reason: ::std::option::Option<crate::types::ValidationExceptionReason>,
67    pub(crate) field_list: ::std::option::Option<::std::vec::Vec<crate::types::ValidationExceptionField>>,
68    meta: std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
69}
70impl ValidationExceptionBuilder {
71    /// <p>A description of the error.</p>
72    /// This field is required.
73    pub fn message(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
74        self.message = ::std::option::Option::Some(input.into());
75        self
76    }
77    /// <p>A description of the error.</p>
78    pub fn set_message(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
79        self.message = input;
80        self
81    }
82    /// <p>A description of the error.</p>
83    pub fn get_message(&self) -> &::std::option::Option<::std::string::String> {
84        &self.message
85    }
86    /// <p>The reason that the operation failed.</p>
87    /// This field is required.
88    pub fn reason(mut self, input: crate::types::ValidationExceptionReason) -> Self {
89        self.reason = ::std::option::Option::Some(input);
90        self
91    }
92    /// <p>The reason that the operation failed.</p>
93    pub fn set_reason(mut self, input: ::std::option::Option<crate::types::ValidationExceptionReason>) -> Self {
94        self.reason = input;
95        self
96    }
97    /// <p>The reason that the operation failed.</p>
98    pub fn get_reason(&self) -> &::std::option::Option<crate::types::ValidationExceptionReason> {
99        &self.reason
100    }
101    /// Appends an item to `field_list`.
102    ///
103    /// To override the contents of this collection use [`set_field_list`](Self::set_field_list).
104    ///
105    /// <p>A list of fields that might be associated with the error.</p>
106    pub fn field_list(mut self, input: crate::types::ValidationExceptionField) -> Self {
107        let mut v = self.field_list.unwrap_or_default();
108        v.push(input);
109        self.field_list = ::std::option::Option::Some(v);
110        self
111    }
112    /// <p>A list of fields that might be associated with the error.</p>
113    pub fn set_field_list(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::ValidationExceptionField>>) -> Self {
114        self.field_list = input;
115        self
116    }
117    /// <p>A list of fields that might be associated with the error.</p>
118    pub fn get_field_list(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::ValidationExceptionField>> {
119        &self.field_list
120    }
121    /// Sets error metadata
122    pub fn meta(mut self, meta: ::aws_smithy_types::error::ErrorMetadata) -> Self {
123        self.meta = Some(meta);
124        self
125    }
126
127    /// Sets error metadata
128    pub fn set_meta(&mut self, meta: std::option::Option<::aws_smithy_types::error::ErrorMetadata>) -> &mut Self {
129        self.meta = meta;
130        self
131    }
132    /// Consumes the builder and constructs a [`ValidationException`](crate::types::error::ValidationException).
133    /// This method will fail if any of the following fields are not set:
134    /// - [`message`](crate::types::error::builders::ValidationExceptionBuilder::message)
135    /// - [`reason`](crate::types::error::builders::ValidationExceptionBuilder::reason)
136    pub fn build(self) -> ::std::result::Result<crate::types::error::ValidationException, ::aws_smithy_types::error::operation::BuildError> {
137        ::std::result::Result::Ok(crate::types::error::ValidationException {
138            message: self.message.ok_or_else(|| {
139                ::aws_smithy_types::error::operation::BuildError::missing_field(
140                    "message",
141                    "message was not specified but it is required when building ValidationException",
142                )
143            })?,
144            reason: self.reason.ok_or_else(|| {
145                ::aws_smithy_types::error::operation::BuildError::missing_field(
146                    "reason",
147                    "reason was not specified but it is required when building ValidationException",
148                )
149            })?,
150            field_list: self.field_list,
151            meta: self.meta.unwrap_or_default(),
152        })
153    }
154}