bitwarden_core/auth/api/response/
identity_token_fail_response.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use core::fmt;

use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
pub struct IdentityTokenFailResponse {
    pub error: String,
    pub error_description: String,
    #[serde(alias = "ErrorModel")]
    pub error_model: ErrorModel,
}

impl fmt::Display for IdentityTokenFailResponse {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let msg = match self.error_model.message.trim().is_empty() {
            true => format!("{}: {}", self.error, self.error_description),
            false => self.error_model.message.clone(),
        };

        write!(f, "{}", msg)
    }
}

#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
pub struct ErrorModel {
    #[serde(alias = "Message")]
    pub message: String,
    #[serde(alias = "Object")]
    object: String,
}

impl fmt::Display for ErrorModel {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{}", self.message)
    }
}