(&self)
| 43 | } |
| 44 | |
| 45 | pub fn to_json_string(&self) -> String { |
| 46 | let mut map = HashMap::new(); |
| 47 | map.insert("code".to_string(), self.code.clone()); |
| 48 | map.insert( |
| 49 | "message".to_string(), |
| 50 | self.message.clone().unwrap_or("".to_string()), |
| 51 | ); |
| 52 | map.insert( |
| 53 | "details".to_string(), |
| 54 | json!(&self.details.clone().unwrap_or_default()).to_string(), |
| 55 | ); |
| 56 | |
| 57 | json!(map).to_string() |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | pub trait DetailableError { |