Skip to main content

nominal_api/conjure/objects/api/
error_result.rs

1#[derive(
2    Debug,
3    Clone,
4    conjure_object::serde::Serialize,
5    conjure_object::serde::Deserialize,
6    PartialEq,
7    Eq,
8    PartialOrd,
9    Ord,
10    Hash
11)]
12#[serde(crate = "conjure_object::serde")]
13#[conjure_object::private::staged_builder::staged_builder]
14#[builder(crate = conjure_object::private::staged_builder, update, inline)]
15pub struct ErrorResult {
16    #[builder(into)]
17    #[serde(rename = "errorType")]
18    error_type: String,
19    #[builder(into)]
20    #[serde(rename = "message")]
21    message: String,
22    #[builder(default, into)]
23    #[serde(
24        rename = "errorInstanceId",
25        skip_serializing_if = "Option::is_none",
26        default
27    )]
28    error_instance_id: Option<String>,
29}
30impl ErrorResult {
31    /// Constructs a new instance of the type.
32    #[inline]
33    pub fn new(error_type: impl Into<String>, message: impl Into<String>) -> Self {
34        Self::builder().error_type(error_type).message(message).build()
35    }
36    #[inline]
37    pub fn error_type(&self) -> &str {
38        &*self.error_type
39    }
40    #[inline]
41    pub fn message(&self) -> &str {
42        &*self.message
43    }
44    #[inline]
45    pub fn error_instance_id(&self) -> Option<&str> {
46        self.error_instance_id.as_ref().map(|o| &**o)
47    }
48}